documentation.d.ts 3.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = linear */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Classed used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * This function is deprecated. Use FromArray instead
  2671. * @param array defines the source array
  2672. * @param offset defines the offset in the source array
  2673. * @returns the new Vector3
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * This function is deprecated. Use FromArrayToRef instead.
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Creates a right-handed perspective projection matrix
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed perspective projection matrix
  4467. */
  4468. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed perspective projection into a given matrix
  4471. * @param fov defines the horizontal field of view
  4472. * @param aspect defines the aspect ratio
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4477. */
  4478. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4479. /**
  4480. * Stores a perspective projection for WebVR info a given matrix
  4481. * @param fov defines the field of view
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @param result defines the target matrix
  4485. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4486. */
  4487. static PerspectiveFovWebVRToRef(fov: {
  4488. upDegrees: number;
  4489. downDegrees: number;
  4490. leftDegrees: number;
  4491. rightDegrees: number;
  4492. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4493. /**
  4494. * Computes a complete transformation matrix
  4495. * @param viewport defines the viewport to use
  4496. * @param world defines the world matrix
  4497. * @param view defines the view matrix
  4498. * @param projection defines the projection matrix
  4499. * @param zmin defines the near clip plane
  4500. * @param zmax defines the far clip plane
  4501. * @returns the transformation matrix
  4502. */
  4503. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4504. /**
  4505. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4506. * @param matrix defines the matrix to use
  4507. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4508. */
  4509. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4510. /**
  4511. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4512. * @param matrix defines the matrix to use
  4513. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4514. */
  4515. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4516. /**
  4517. * Compute the transpose of a given matrix
  4518. * @param matrix defines the matrix to transpose
  4519. * @returns the new matrix
  4520. */
  4521. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4522. /**
  4523. * Compute the transpose of a matrix and store it in a target matrix
  4524. * @param matrix defines the matrix to transpose
  4525. * @param result defines the target matrix
  4526. */
  4527. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4528. /**
  4529. * Computes a reflection matrix from a plane
  4530. * @param plane defines the reflection plane
  4531. * @returns a new matrix
  4532. */
  4533. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4534. /**
  4535. * Computes a reflection matrix from a plane
  4536. * @param plane defines the reflection plane
  4537. * @param result defines the target matrix
  4538. */
  4539. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4540. /**
  4541. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4542. * @param xaxis defines the value of the 1st axis
  4543. * @param yaxis defines the value of the 2nd axis
  4544. * @param zaxis defines the value of the 3rd axis
  4545. * @param result defines the target matrix
  4546. */
  4547. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4550. * @param quat defines the quaternion to use
  4551. * @param result defines the target matrix
  4552. */
  4553. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4554. }
  4555. /**
  4556. * @hidden
  4557. */
  4558. export class TmpVectors {
  4559. static Vector2: Vector2[];
  4560. static Vector3: Vector3[];
  4561. static Vector4: Vector4[];
  4562. static Quaternion: Quaternion[];
  4563. static Matrix: Matrix[];
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Defines potential orientation for back face culling
  4569. */
  4570. export enum Orientation {
  4571. /**
  4572. * Clockwise
  4573. */
  4574. CW = 0,
  4575. /** Counter clockwise */
  4576. CCW = 1
  4577. }
  4578. /** Class used to represent a Bezier curve */
  4579. export class BezierCurve {
  4580. /**
  4581. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4582. * @param t defines the time
  4583. * @param x1 defines the left coordinate on X axis
  4584. * @param y1 defines the left coordinate on Y axis
  4585. * @param x2 defines the right coordinate on X axis
  4586. * @param y2 defines the right coordinate on Y axis
  4587. * @returns the interpolated value
  4588. */
  4589. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4590. }
  4591. /**
  4592. * Defines angle representation
  4593. */
  4594. export class Angle {
  4595. private _radians;
  4596. /**
  4597. * Creates an Angle object of "radians" radians (float).
  4598. * @param radians the angle in radians
  4599. */
  4600. constructor(radians: number);
  4601. /**
  4602. * Get value in degrees
  4603. * @returns the Angle value in degrees (float)
  4604. */
  4605. degrees(): number;
  4606. /**
  4607. * Get value in radians
  4608. * @returns the Angle value in radians (float)
  4609. */
  4610. radians(): number;
  4611. /**
  4612. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4613. * @param a defines first vector
  4614. * @param b defines second vector
  4615. * @returns a new Angle
  4616. */
  4617. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4618. /**
  4619. * Gets a new Angle object from the given float in radians
  4620. * @param radians defines the angle value in radians
  4621. * @returns a new Angle
  4622. */
  4623. static FromRadians(radians: number): Angle;
  4624. /**
  4625. * Gets a new Angle object from the given float in degrees
  4626. * @param degrees defines the angle value in degrees
  4627. * @returns a new Angle
  4628. */
  4629. static FromDegrees(degrees: number): Angle;
  4630. }
  4631. /**
  4632. * This represents an arc in a 2d space.
  4633. */
  4634. export class Arc2 {
  4635. /** Defines the start point of the arc */
  4636. startPoint: Vector2;
  4637. /** Defines the mid point of the arc */
  4638. midPoint: Vector2;
  4639. /** Defines the end point of the arc */
  4640. endPoint: Vector2;
  4641. /**
  4642. * Defines the center point of the arc.
  4643. */
  4644. centerPoint: Vector2;
  4645. /**
  4646. * Defines the radius of the arc.
  4647. */
  4648. radius: number;
  4649. /**
  4650. * Defines the angle of the arc (from mid point to end point).
  4651. */
  4652. angle: Angle;
  4653. /**
  4654. * Defines the start angle of the arc (from start point to middle point).
  4655. */
  4656. startAngle: Angle;
  4657. /**
  4658. * Defines the orientation of the arc (clock wise/counter clock wise).
  4659. */
  4660. orientation: Orientation;
  4661. /**
  4662. * Creates an Arc object from the three given points : start, middle and end.
  4663. * @param startPoint Defines the start point of the arc
  4664. * @param midPoint Defines the midlle point of the arc
  4665. * @param endPoint Defines the end point of the arc
  4666. */
  4667. constructor(
  4668. /** Defines the start point of the arc */
  4669. startPoint: Vector2,
  4670. /** Defines the mid point of the arc */
  4671. midPoint: Vector2,
  4672. /** Defines the end point of the arc */
  4673. endPoint: Vector2);
  4674. }
  4675. /**
  4676. * Represents a 2D path made up of multiple 2D points
  4677. */
  4678. export class Path2 {
  4679. private _points;
  4680. private _length;
  4681. /**
  4682. * If the path start and end point are the same
  4683. */
  4684. closed: boolean;
  4685. /**
  4686. * Creates a Path2 object from the starting 2D coordinates x and y.
  4687. * @param x the starting points x value
  4688. * @param y the starting points y value
  4689. */
  4690. constructor(x: number, y: number);
  4691. /**
  4692. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4693. * @param x the added points x value
  4694. * @param y the added points y value
  4695. * @returns the updated Path2.
  4696. */
  4697. addLineTo(x: number, y: number): Path2;
  4698. /**
  4699. * 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.
  4700. * @param midX middle point x value
  4701. * @param midY middle point y value
  4702. * @param endX end point x value
  4703. * @param endY end point y value
  4704. * @param numberOfSegments (default: 36)
  4705. * @returns the updated Path2.
  4706. */
  4707. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4708. /**
  4709. * Closes the Path2.
  4710. * @returns the Path2.
  4711. */
  4712. close(): Path2;
  4713. /**
  4714. * Gets the sum of the distance between each sequential point in the path
  4715. * @returns the Path2 total length (float).
  4716. */
  4717. length(): number;
  4718. /**
  4719. * Gets the points which construct the path
  4720. * @returns the Path2 internal array of points.
  4721. */
  4722. getPoints(): Vector2[];
  4723. /**
  4724. * Retreives the point at the distance aways from the starting point
  4725. * @param normalizedLengthPosition the length along the path to retreive the point from
  4726. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4727. */
  4728. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4729. /**
  4730. * Creates a new path starting from an x and y position
  4731. * @param x starting x value
  4732. * @param y starting y value
  4733. * @returns a new Path2 starting at the coordinates (x, y).
  4734. */
  4735. static StartingAt(x: number, y: number): Path2;
  4736. }
  4737. /**
  4738. * Represents a 3D path made up of multiple 3D points
  4739. */
  4740. export class Path3D {
  4741. /**
  4742. * an array of Vector3, the curve axis of the Path3D
  4743. */
  4744. path: Vector3[];
  4745. private _curve;
  4746. private _distances;
  4747. private _tangents;
  4748. private _normals;
  4749. private _binormals;
  4750. private _raw;
  4751. /**
  4752. * new Path3D(path, normal, raw)
  4753. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4754. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4755. * @param path an array of Vector3, the curve axis of the Path3D
  4756. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4757. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4758. */
  4759. constructor(
  4760. /**
  4761. * an array of Vector3, the curve axis of the Path3D
  4762. */
  4763. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4764. /**
  4765. * Returns the Path3D array of successive Vector3 designing its curve.
  4766. * @returns the Path3D array of successive Vector3 designing its curve.
  4767. */
  4768. getCurve(): Vector3[];
  4769. /**
  4770. * Returns an array populated with tangent vectors on each Path3D curve point.
  4771. * @returns an array populated with tangent vectors on each Path3D curve point.
  4772. */
  4773. getTangents(): Vector3[];
  4774. /**
  4775. * Returns an array populated with normal vectors on each Path3D curve point.
  4776. * @returns an array populated with normal vectors on each Path3D curve point.
  4777. */
  4778. getNormals(): Vector3[];
  4779. /**
  4780. * Returns an array populated with binormal vectors on each Path3D curve point.
  4781. * @returns an array populated with binormal vectors on each Path3D curve point.
  4782. */
  4783. getBinormals(): Vector3[];
  4784. /**
  4785. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4786. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4787. */
  4788. getDistances(): number[];
  4789. /**
  4790. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4791. * @param path path which all values are copied into the curves points
  4792. * @param firstNormal which should be projected onto the curve
  4793. * @returns the same object updated.
  4794. */
  4795. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4796. private _compute;
  4797. private _getFirstNonNullVector;
  4798. private _getLastNonNullVector;
  4799. private _normalVector;
  4800. }
  4801. /**
  4802. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4803. * A Curve3 is designed from a series of successive Vector3.
  4804. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4805. */
  4806. export class Curve3 {
  4807. private _points;
  4808. private _length;
  4809. /**
  4810. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4811. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4812. * @param v1 (Vector3) the control point
  4813. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4820. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4821. * @param v1 (Vector3) the first control point
  4822. * @param v2 (Vector3) the second control point
  4823. * @param v3 (Vector3) the end point of the Cubic Bezier
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4830. * @param p1 (Vector3) the origin point of the Hermite Spline
  4831. * @param t1 (Vector3) the tangent vector at the origin point
  4832. * @param p2 (Vector3) the end point of the Hermite Spline
  4833. * @param t2 (Vector3) the tangent vector at the end point
  4834. * @param nbPoints (integer) the wanted number of points in the curve
  4835. * @returns the created Curve3
  4836. */
  4837. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4838. /**
  4839. * Returns a Curve3 object along a CatmullRom Spline curve :
  4840. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4841. * @param nbPoints (integer) the wanted number of points between each curve control points
  4842. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4843. * @returns the created Curve3
  4844. */
  4845. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4846. /**
  4847. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4848. * A Curve3 is designed from a series of successive Vector3.
  4849. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4850. * @param points points which make up the curve
  4851. */
  4852. constructor(points: Vector3[]);
  4853. /**
  4854. * @returns the Curve3 stored array of successive Vector3
  4855. */
  4856. getPoints(): Vector3[];
  4857. /**
  4858. * @returns the computed length (float) of the curve.
  4859. */
  4860. length(): number;
  4861. /**
  4862. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4863. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4864. * curveA and curveB keep unchanged.
  4865. * @param curve the curve to continue from this curve
  4866. * @returns the newly constructed curve
  4867. */
  4868. continue(curve: DeepImmutable<Curve3>): Curve3;
  4869. private _computeLength;
  4870. }
  4871. }
  4872. declare module BABYLON {
  4873. /**
  4874. * This represents the main contract an easing function should follow.
  4875. * Easing functions are used throughout the animation system.
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. export interface IEasingFunction {
  4879. /**
  4880. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4881. * of the easing function.
  4882. * The link below provides some of the most common examples of easing functions.
  4883. * @see https://easings.net/
  4884. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4885. * @returns the corresponding value on the curve defined by the easing function
  4886. */
  4887. ease(gradient: number): number;
  4888. }
  4889. /**
  4890. * Base class used for every default easing function.
  4891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4892. */
  4893. export class EasingFunction implements IEasingFunction {
  4894. /**
  4895. * Interpolation follows the mathematical formula associated with the easing function.
  4896. */
  4897. static readonly EASINGMODE_EASEIN: number;
  4898. /**
  4899. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4900. */
  4901. static readonly EASINGMODE_EASEOUT: number;
  4902. /**
  4903. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4904. */
  4905. static readonly EASINGMODE_EASEINOUT: number;
  4906. private _easingMode;
  4907. /**
  4908. * Sets the easing mode of the current function.
  4909. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4910. */
  4911. setEasingMode(easingMode: number): void;
  4912. /**
  4913. * Gets the current easing mode.
  4914. * @returns the easing mode
  4915. */
  4916. getEasingMode(): number;
  4917. /**
  4918. * @hidden
  4919. */
  4920. easeInCore(gradient: number): number;
  4921. /**
  4922. * Given an input gradient between 0 and 1, this returns the corresponding value
  4923. * of the easing function.
  4924. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4925. * @returns the corresponding value on the curve defined by the easing function
  4926. */
  4927. ease(gradient: number): number;
  4928. }
  4929. /**
  4930. * Easing function with a circle shape (see link below).
  4931. * @see https://easings.net/#easeInCirc
  4932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4933. */
  4934. export class CircleEase extends EasingFunction implements IEasingFunction {
  4935. /** @hidden */
  4936. easeInCore(gradient: number): number;
  4937. }
  4938. /**
  4939. * Easing function with a ease back shape (see link below).
  4940. * @see https://easings.net/#easeInBack
  4941. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4942. */
  4943. export class BackEase extends EasingFunction implements IEasingFunction {
  4944. /** Defines the amplitude of the function */
  4945. amplitude: number;
  4946. /**
  4947. * Instantiates a back ease easing
  4948. * @see https://easings.net/#easeInBack
  4949. * @param amplitude Defines the amplitude of the function
  4950. */
  4951. constructor(
  4952. /** Defines the amplitude of the function */
  4953. amplitude?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a bouncing shape (see link below).
  4959. * @see https://easings.net/#easeInBounce
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class BounceEase extends EasingFunction implements IEasingFunction {
  4963. /** Defines the number of bounces */
  4964. bounces: number;
  4965. /** Defines the amplitude of the bounce */
  4966. bounciness: number;
  4967. /**
  4968. * Instantiates a bounce easing
  4969. * @see https://easings.net/#easeInBounce
  4970. * @param bounces Defines the number of bounces
  4971. * @param bounciness Defines the amplitude of the bounce
  4972. */
  4973. constructor(
  4974. /** Defines the number of bounces */
  4975. bounces?: number,
  4976. /** Defines the amplitude of the bounce */
  4977. bounciness?: number);
  4978. /** @hidden */
  4979. easeInCore(gradient: number): number;
  4980. }
  4981. /**
  4982. * Easing function with a power of 3 shape (see link below).
  4983. * @see https://easings.net/#easeInCubic
  4984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4985. */
  4986. export class CubicEase extends EasingFunction implements IEasingFunction {
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an elastic shape (see link below).
  4992. * @see https://easings.net/#easeInElastic
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the number of oscillations*/
  4997. oscillations: number;
  4998. /** Defines the amplitude of the oscillations*/
  4999. springiness: number;
  5000. /**
  5001. * Instantiates an elastic easing function
  5002. * @see https://easings.net/#easeInElastic
  5003. * @param oscillations Defines the number of oscillations
  5004. * @param springiness Defines the amplitude of the oscillations
  5005. */
  5006. constructor(
  5007. /** Defines the number of oscillations*/
  5008. oscillations?: number,
  5009. /** Defines the amplitude of the oscillations*/
  5010. springiness?: number);
  5011. /** @hidden */
  5012. easeInCore(gradient: number): number;
  5013. }
  5014. /**
  5015. * Easing function with an exponential shape (see link below).
  5016. * @see https://easings.net/#easeInExpo
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5020. /** Defines the exponent of the function */
  5021. exponent: number;
  5022. /**
  5023. * Instantiates an exponential easing function
  5024. * @see https://easings.net/#easeInExpo
  5025. * @param exponent Defines the exponent of the function
  5026. */
  5027. constructor(
  5028. /** Defines the exponent of the function */
  5029. exponent?: number);
  5030. /** @hidden */
  5031. easeInCore(gradient: number): number;
  5032. }
  5033. /**
  5034. * Easing function with a power shape (see link below).
  5035. * @see https://easings.net/#easeInQuad
  5036. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5037. */
  5038. export class PowerEase extends EasingFunction implements IEasingFunction {
  5039. /** Defines the power of the function */
  5040. power: number;
  5041. /**
  5042. * Instantiates an power base easing function
  5043. * @see https://easings.net/#easeInQuad
  5044. * @param power Defines the power of the function
  5045. */
  5046. constructor(
  5047. /** Defines the power of the function */
  5048. power?: number);
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a power of 2 shape (see link below).
  5054. * @see https://easings.net/#easeInQuad
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5058. /** @hidden */
  5059. easeInCore(gradient: number): number;
  5060. }
  5061. /**
  5062. * Easing function with a power of 4 shape (see link below).
  5063. * @see https://easings.net/#easeInQuart
  5064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5065. */
  5066. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5067. /** @hidden */
  5068. easeInCore(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a power of 5 shape (see link below).
  5072. * @see https://easings.net/#easeInQuint
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a sin shape (see link below).
  5081. * @see https://easings.net/#easeInSine
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class SineEase extends EasingFunction implements IEasingFunction {
  5085. /** @hidden */
  5086. easeInCore(gradient: number): number;
  5087. }
  5088. /**
  5089. * Easing function with a bezier shape (see link below).
  5090. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5092. */
  5093. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5094. /** Defines the x component of the start tangent in the bezier curve */
  5095. x1: number;
  5096. /** Defines the y component of the start tangent in the bezier curve */
  5097. y1: number;
  5098. /** Defines the x component of the end tangent in the bezier curve */
  5099. x2: number;
  5100. /** Defines the y component of the end tangent in the bezier curve */
  5101. y2: number;
  5102. /**
  5103. * Instantiates a bezier function
  5104. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5105. * @param x1 Defines the x component of the start tangent in the bezier curve
  5106. * @param y1 Defines the y component of the start tangent in the bezier curve
  5107. * @param x2 Defines the x component of the end tangent in the bezier curve
  5108. * @param y2 Defines the y component of the end tangent in the bezier curve
  5109. */
  5110. constructor(
  5111. /** Defines the x component of the start tangent in the bezier curve */
  5112. x1?: number,
  5113. /** Defines the y component of the start tangent in the bezier curve */
  5114. y1?: number,
  5115. /** Defines the x component of the end tangent in the bezier curve */
  5116. x2?: number,
  5117. /** Defines the y component of the end tangent in the bezier curve */
  5118. y2?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. }
  5123. declare module BABYLON {
  5124. /**
  5125. * Class used to hold a RBG color
  5126. */
  5127. export class Color3 {
  5128. /**
  5129. * Defines the red component (between 0 and 1, default is 0)
  5130. */
  5131. r: number;
  5132. /**
  5133. * Defines the green component (between 0 and 1, default is 0)
  5134. */
  5135. g: number;
  5136. /**
  5137. * Defines the blue component (between 0 and 1, default is 0)
  5138. */
  5139. b: number;
  5140. /**
  5141. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5142. * @param r defines the red component (between 0 and 1, default is 0)
  5143. * @param g defines the green component (between 0 and 1, default is 0)
  5144. * @param b defines the blue component (between 0 and 1, default is 0)
  5145. */
  5146. constructor(
  5147. /**
  5148. * Defines the red component (between 0 and 1, default is 0)
  5149. */
  5150. r?: number,
  5151. /**
  5152. * Defines the green component (between 0 and 1, default is 0)
  5153. */
  5154. g?: number,
  5155. /**
  5156. * Defines the blue component (between 0 and 1, default is 0)
  5157. */
  5158. b?: number);
  5159. /**
  5160. * Creates a string with the Color3 current values
  5161. * @returns the string representation of the Color3 object
  5162. */
  5163. toString(): string;
  5164. /**
  5165. * Returns the string "Color3"
  5166. * @returns "Color3"
  5167. */
  5168. getClassName(): string;
  5169. /**
  5170. * Compute the Color3 hash code
  5171. * @returns an unique number that can be used to hash Color3 objects
  5172. */
  5173. getHashCode(): number;
  5174. /**
  5175. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5176. * @param array defines the array where to store the r,g,b components
  5177. * @param index defines an optional index in the target array to define where to start storing values
  5178. * @returns the current Color3 object
  5179. */
  5180. toArray(array: FloatArray, index?: number): Color3;
  5181. /**
  5182. * Returns a new Color4 object from the current Color3 and the given alpha
  5183. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5184. * @returns a new Color4 object
  5185. */
  5186. toColor4(alpha?: number): Color4;
  5187. /**
  5188. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5189. * @returns the new array
  5190. */
  5191. asArray(): number[];
  5192. /**
  5193. * Returns the luminance value
  5194. * @returns a float value
  5195. */
  5196. toLuminance(): number;
  5197. /**
  5198. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5199. * @param otherColor defines the second operand
  5200. * @returns the new Color3 object
  5201. */
  5202. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5203. /**
  5204. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5205. * @param otherColor defines the second operand
  5206. * @param result defines the Color3 object where to store the result
  5207. * @returns the current Color3
  5208. */
  5209. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5210. /**
  5211. * Determines equality between Color3 objects
  5212. * @param otherColor defines the second operand
  5213. * @returns true if the rgb values are equal to the given ones
  5214. */
  5215. equals(otherColor: DeepImmutable<Color3>): boolean;
  5216. /**
  5217. * Determines equality between the current Color3 object and a set of r,b,g values
  5218. * @param r defines the red component to check
  5219. * @param g defines the green component to check
  5220. * @param b defines the blue component to check
  5221. * @returns true if the rgb values are equal to the given ones
  5222. */
  5223. equalsFloats(r: number, g: number, b: number): boolean;
  5224. /**
  5225. * Multiplies in place each rgb value by scale
  5226. * @param scale defines the scaling factor
  5227. * @returns the updated Color3
  5228. */
  5229. scale(scale: number): Color3;
  5230. /**
  5231. * Multiplies the rgb values by scale and stores the result into "result"
  5232. * @param scale defines the scaling factor
  5233. * @param result defines the Color3 object where to store the result
  5234. * @returns the unmodified current Color3
  5235. */
  5236. scaleToRef(scale: number, result: Color3): Color3;
  5237. /**
  5238. * Scale the current Color3 values by a factor and add the result to a given Color3
  5239. * @param scale defines the scale factor
  5240. * @param result defines color to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5244. /**
  5245. * Clamps the rgb values by the min and max values and stores the result into "result"
  5246. * @param min defines minimum clamping value (default is 0)
  5247. * @param max defines maximum clamping value (default is 1)
  5248. * @param result defines color to store the result into
  5249. * @returns the original Color3
  5250. */
  5251. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5252. /**
  5253. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5254. * @param otherColor defines the second operand
  5255. * @returns the new Color3
  5256. */
  5257. add(otherColor: DeepImmutable<Color3>): Color3;
  5258. /**
  5259. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5260. * @param otherColor defines the second operand
  5261. * @param result defines Color3 object to store the result into
  5262. * @returns the unmodified current Color3
  5263. */
  5264. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5265. /**
  5266. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5267. * @param otherColor defines the second operand
  5268. * @returns the new Color3
  5269. */
  5270. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5271. /**
  5272. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5273. * @param otherColor defines the second operand
  5274. * @param result defines Color3 object to store the result into
  5275. * @returns the unmodified current Color3
  5276. */
  5277. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5278. /**
  5279. * Copy the current object
  5280. * @returns a new Color3 copied the current one
  5281. */
  5282. clone(): Color3;
  5283. /**
  5284. * Copies the rgb values from the source in the current Color3
  5285. * @param source defines the source Color3 object
  5286. * @returns the updated Color3 object
  5287. */
  5288. copyFrom(source: DeepImmutable<Color3>): Color3;
  5289. /**
  5290. * Updates the Color3 rgb values from the given floats
  5291. * @param r defines the red component to read from
  5292. * @param g defines the green component to read from
  5293. * @param b defines the blue component to read from
  5294. * @returns the current Color3 object
  5295. */
  5296. copyFromFloats(r: number, g: number, b: number): Color3;
  5297. /**
  5298. * Updates the Color3 rgb values from the given floats
  5299. * @param r defines the red component to read from
  5300. * @param g defines the green component to read from
  5301. * @param b defines the blue component to read from
  5302. * @returns the current Color3 object
  5303. */
  5304. set(r: number, g: number, b: number): Color3;
  5305. /**
  5306. * Compute the Color3 hexadecimal code as a string
  5307. * @returns a string containing the hexadecimal representation of the Color3 object
  5308. */
  5309. toHexString(): string;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to linear space
  5312. * @returns a new Color3 object
  5313. */
  5314. toLinearSpace(): Color3;
  5315. /**
  5316. * Converts current color in rgb space to HSV values
  5317. * @returns a new color3 representing the HSV values
  5318. */
  5319. toHSV(): Color3;
  5320. /**
  5321. * Converts current color in rgb space to HSV values
  5322. * @param result defines the Color3 where to store the HSV values
  5323. */
  5324. toHSVToRef(result: Color3): void;
  5325. /**
  5326. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5327. * @param convertedColor defines the Color3 object where to store the linear space version
  5328. * @returns the unmodified Color3
  5329. */
  5330. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5331. /**
  5332. * Computes a new Color3 converted from the current one to gamma space
  5333. * @returns a new Color3 object
  5334. */
  5335. toGammaSpace(): Color3;
  5336. /**
  5337. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5338. * @param convertedColor defines the Color3 object where to store the gamma space version
  5339. * @returns the unmodified Color3
  5340. */
  5341. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5342. private static _BlackReadOnly;
  5343. /**
  5344. * Convert Hue, saturation and value to a Color3 (RGB)
  5345. * @param hue defines the hue
  5346. * @param saturation defines the saturation
  5347. * @param value defines the value
  5348. * @param result defines the Color3 where to store the RGB values
  5349. */
  5350. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5351. /**
  5352. * Creates a new Color3 from the string containing valid hexadecimal values
  5353. * @param hex defines a string containing valid hexadecimal values
  5354. * @returns a new Color3 object
  5355. */
  5356. static FromHexString(hex: string): Color3;
  5357. /**
  5358. * Creates a new Color3 from the starting index of the given array
  5359. * @param array defines the source array
  5360. * @param offset defines an offset in the source array
  5361. * @returns a new Color3 object
  5362. */
  5363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5364. /**
  5365. * Creates a new Color3 from integer values (< 256)
  5366. * @param r defines the red component to read from (value between 0 and 255)
  5367. * @param g defines the green component to read from (value between 0 and 255)
  5368. * @param b defines the blue component to read from (value between 0 and 255)
  5369. * @returns a new Color3 object
  5370. */
  5371. static FromInts(r: number, g: number, b: number): Color3;
  5372. /**
  5373. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5374. * @param start defines the start Color3 value
  5375. * @param end defines the end Color3 value
  5376. * @param amount defines the gradient value between start and end
  5377. * @returns a new Color3 object
  5378. */
  5379. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5380. /**
  5381. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5382. * @param left defines the start value
  5383. * @param right defines the end value
  5384. * @param amount defines the gradient factor
  5385. * @param result defines the Color3 object where to store the result
  5386. */
  5387. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5388. /**
  5389. * Returns a Color3 value containing a red color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Red(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a green color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Green(): Color3;
  5398. /**
  5399. * Returns a Color3 value containing a blue color
  5400. * @returns a new Color3 object
  5401. */
  5402. static Blue(): Color3;
  5403. /**
  5404. * Returns a Color3 value containing a black color
  5405. * @returns a new Color3 object
  5406. */
  5407. static Black(): Color3;
  5408. /**
  5409. * Gets a Color3 value containing a black color that must not be updated
  5410. */
  5411. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5412. /**
  5413. * Returns a Color3 value containing a white color
  5414. * @returns a new Color3 object
  5415. */
  5416. static White(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a purple color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Purple(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a magenta color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Magenta(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a yellow color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Yellow(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a gray color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Gray(): Color3;
  5437. /**
  5438. * Returns a Color3 value containing a teal color
  5439. * @returns a new Color3 object
  5440. */
  5441. static Teal(): Color3;
  5442. /**
  5443. * Returns a Color3 value containing a random color
  5444. * @returns a new Color3 object
  5445. */
  5446. static Random(): Color3;
  5447. }
  5448. /**
  5449. * Class used to hold a RBGA color
  5450. */
  5451. export class Color4 {
  5452. /**
  5453. * Defines the red component (between 0 and 1, default is 0)
  5454. */
  5455. r: number;
  5456. /**
  5457. * Defines the green component (between 0 and 1, default is 0)
  5458. */
  5459. g: number;
  5460. /**
  5461. * Defines the blue component (between 0 and 1, default is 0)
  5462. */
  5463. b: number;
  5464. /**
  5465. * Defines the alpha component (between 0 and 1, default is 1)
  5466. */
  5467. a: number;
  5468. /**
  5469. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5470. * @param r defines the red component (between 0 and 1, default is 0)
  5471. * @param g defines the green component (between 0 and 1, default is 0)
  5472. * @param b defines the blue component (between 0 and 1, default is 0)
  5473. * @param a defines the alpha component (between 0 and 1, default is 1)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number,
  5488. /**
  5489. * Defines the alpha component (between 0 and 1, default is 1)
  5490. */
  5491. a?: number);
  5492. /**
  5493. * Adds in place the given Color4 values to the current Color4 object
  5494. * @param right defines the second operand
  5495. * @returns the current updated Color4 object
  5496. */
  5497. addInPlace(right: DeepImmutable<Color4>): Color4;
  5498. /**
  5499. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5500. * @returns the new array
  5501. */
  5502. asArray(): number[];
  5503. /**
  5504. * Stores from the starting index in the given array the Color4 successive values
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color4 object
  5508. */
  5509. toArray(array: number[], index?: number): Color4;
  5510. /**
  5511. * Determines equality between Color4 objects
  5512. * @param otherColor defines the second operand
  5513. * @returns true if the rgba values are equal to the given ones
  5514. */
  5515. equals(otherColor: DeepImmutable<Color4>): boolean;
  5516. /**
  5517. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5518. * @param right defines the second operand
  5519. * @returns a new Color4 object
  5520. */
  5521. add(right: DeepImmutable<Color4>): Color4;
  5522. /**
  5523. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5524. * @param right defines the second operand
  5525. * @returns a new Color4 object
  5526. */
  5527. subtract(right: DeepImmutable<Color4>): Color4;
  5528. /**
  5529. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5530. * @param right defines the second operand
  5531. * @param result defines the Color4 object where to store the result
  5532. * @returns the current Color4 object
  5533. */
  5534. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5535. /**
  5536. * Creates a new Color4 with the current Color4 values multiplied by scale
  5537. * @param scale defines the scaling factor to apply
  5538. * @returns a new Color4 object
  5539. */
  5540. scale(scale: number): Color4;
  5541. /**
  5542. * Multiplies the current Color4 values by scale and stores the result in "result"
  5543. * @param scale defines the scaling factor to apply
  5544. * @param result defines the Color4 object where to store the result
  5545. * @returns the current unmodified Color4
  5546. */
  5547. scaleToRef(scale: number, result: Color4): Color4;
  5548. /**
  5549. * Scale the current Color4 values by a factor and add the result to a given Color4
  5550. * @param scale defines the scale factor
  5551. * @param result defines the Color4 object where to store the result
  5552. * @returns the unmodified current Color4
  5553. */
  5554. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5555. /**
  5556. * Clamps the rgb values by the min and max values and stores the result into "result"
  5557. * @param min defines minimum clamping value (default is 0)
  5558. * @param max defines maximum clamping value (default is 1)
  5559. * @param result defines color to store the result into.
  5560. * @returns the cuurent Color4
  5561. */
  5562. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5563. /**
  5564. * Multipy an Color4 value by another and return a new Color4 object
  5565. * @param color defines the Color4 value to multiply by
  5566. * @returns a new Color4 object
  5567. */
  5568. multiply(color: Color4): Color4;
  5569. /**
  5570. * Multipy a Color4 value by another and push the result in a reference value
  5571. * @param color defines the Color4 value to multiply by
  5572. * @param result defines the Color4 to fill the result in
  5573. * @returns the result Color4
  5574. */
  5575. multiplyToRef(color: Color4, result: Color4): Color4;
  5576. /**
  5577. * Creates a string with the Color4 current values
  5578. * @returns the string representation of the Color4 object
  5579. */
  5580. toString(): string;
  5581. /**
  5582. * Returns the string "Color4"
  5583. * @returns "Color4"
  5584. */
  5585. getClassName(): string;
  5586. /**
  5587. * Compute the Color4 hash code
  5588. * @returns an unique number that can be used to hash Color4 objects
  5589. */
  5590. getHashCode(): number;
  5591. /**
  5592. * Creates a new Color4 copied from the current one
  5593. * @returns a new Color4 object
  5594. */
  5595. clone(): Color4;
  5596. /**
  5597. * Copies the given Color4 values into the current one
  5598. * @param source defines the source Color4 object
  5599. * @returns the current updated Color4 object
  5600. */
  5601. copyFrom(source: Color4): Color4;
  5602. /**
  5603. * Copies the given float values into the current one
  5604. * @param r defines the red component to read from
  5605. * @param g defines the green component to read from
  5606. * @param b defines the blue component to read from
  5607. * @param a defines the alpha component to read from
  5608. * @returns the current updated Color4 object
  5609. */
  5610. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5611. /**
  5612. * Copies the given float values into the current one
  5613. * @param r defines the red component to read from
  5614. * @param g defines the green component to read from
  5615. * @param b defines the blue component to read from
  5616. * @param a defines the alpha component to read from
  5617. * @returns the current updated Color4 object
  5618. */
  5619. set(r: number, g: number, b: number, a: number): Color4;
  5620. /**
  5621. * Compute the Color4 hexadecimal code as a string
  5622. * @returns a string containing the hexadecimal representation of the Color4 object
  5623. */
  5624. toHexString(): string;
  5625. /**
  5626. * Computes a new Color4 converted from the current one to linear space
  5627. * @returns a new Color4 object
  5628. */
  5629. toLinearSpace(): Color4;
  5630. /**
  5631. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5632. * @param convertedColor defines the Color4 object where to store the linear space version
  5633. * @returns the unmodified Color4
  5634. */
  5635. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5636. /**
  5637. * Computes a new Color4 converted from the current one to gamma space
  5638. * @returns a new Color4 object
  5639. */
  5640. toGammaSpace(): Color4;
  5641. /**
  5642. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5643. * @param convertedColor defines the Color4 object where to store the gamma space version
  5644. * @returns the unmodified Color4
  5645. */
  5646. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5647. /**
  5648. * Creates a new Color4 from the string containing valid hexadecimal values
  5649. * @param hex defines a string containing valid hexadecimal values
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromHexString(hex: string): Color4;
  5653. /**
  5654. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5655. * @param left defines the start value
  5656. * @param right defines the end value
  5657. * @param amount defines the gradient factor
  5658. * @returns a new Color4 object
  5659. */
  5660. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5661. /**
  5662. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5663. * @param left defines the start value
  5664. * @param right defines the end value
  5665. * @param amount defines the gradient factor
  5666. * @param result defines the Color4 object where to store data
  5667. */
  5668. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5669. /**
  5670. * Creates a new Color4 from a Color3 and an alpha value
  5671. * @param color3 defines the source Color3 to read from
  5672. * @param alpha defines the alpha component (1.0 by default)
  5673. * @returns a new Color4 object
  5674. */
  5675. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5676. /**
  5677. * Creates a new Color4 from the starting index element of the given array
  5678. * @param array defines the source array to read from
  5679. * @param offset defines the offset in the source array
  5680. * @returns a new Color4 object
  5681. */
  5682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5683. /**
  5684. * Creates a new Color3 from integer values (< 256)
  5685. * @param r defines the red component to read from (value between 0 and 255)
  5686. * @param g defines the green component to read from (value between 0 and 255)
  5687. * @param b defines the blue component to read from (value between 0 and 255)
  5688. * @param a defines the alpha component to read from (value between 0 and 255)
  5689. * @returns a new Color3 object
  5690. */
  5691. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5692. /**
  5693. * Check the content of a given array and convert it to an array containing RGBA data
  5694. * If the original array was already containing count * 4 values then it is returned directly
  5695. * @param colors defines the array to check
  5696. * @param count defines the number of RGBA data to expect
  5697. * @returns an array containing count * 4 values (RGBA)
  5698. */
  5699. static CheckColors4(colors: number[], count: number): number[];
  5700. }
  5701. /**
  5702. * @hidden
  5703. */
  5704. export class TmpColors {
  5705. static Color3: Color3[];
  5706. static Color4: Color4[];
  5707. }
  5708. }
  5709. declare module BABYLON {
  5710. /**
  5711. * Defines an interface which represents an animation key frame
  5712. */
  5713. export interface IAnimationKey {
  5714. /**
  5715. * Frame of the key frame
  5716. */
  5717. frame: number;
  5718. /**
  5719. * Value at the specifies key frame
  5720. */
  5721. value: any;
  5722. /**
  5723. * The input tangent for the cubic hermite spline
  5724. */
  5725. inTangent?: any;
  5726. /**
  5727. * The output tangent for the cubic hermite spline
  5728. */
  5729. outTangent?: any;
  5730. /**
  5731. * The animation interpolation type
  5732. */
  5733. interpolation?: AnimationKeyInterpolation;
  5734. }
  5735. /**
  5736. * Enum for the animation key frame interpolation type
  5737. */
  5738. export enum AnimationKeyInterpolation {
  5739. /**
  5740. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5741. */
  5742. STEP = 1
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Represents the range of an animation
  5748. */
  5749. export class AnimationRange {
  5750. /**The name of the animation range**/
  5751. name: string;
  5752. /**The starting frame of the animation */
  5753. from: number;
  5754. /**The ending frame of the animation*/
  5755. to: number;
  5756. /**
  5757. * Initializes the range of an animation
  5758. * @param name The name of the animation range
  5759. * @param from The starting frame of the animation
  5760. * @param to The ending frame of the animation
  5761. */
  5762. constructor(
  5763. /**The name of the animation range**/
  5764. name: string,
  5765. /**The starting frame of the animation */
  5766. from: number,
  5767. /**The ending frame of the animation*/
  5768. to: number);
  5769. /**
  5770. * Makes a copy of the animation range
  5771. * @returns A copy of the animation range
  5772. */
  5773. clone(): AnimationRange;
  5774. }
  5775. }
  5776. declare module BABYLON {
  5777. /**
  5778. * Composed of a frame, and an action function
  5779. */
  5780. export class AnimationEvent {
  5781. /** The frame for which the event is triggered **/
  5782. frame: number;
  5783. /** The event to perform when triggered **/
  5784. action: (currentFrame: number) => void;
  5785. /** Specifies if the event should be triggered only once**/
  5786. onlyOnce?: boolean | undefined;
  5787. /**
  5788. * Specifies if the animation event is done
  5789. */
  5790. isDone: boolean;
  5791. /**
  5792. * Initializes the animation event
  5793. * @param frame The frame for which the event is triggered
  5794. * @param action The event to perform when triggered
  5795. * @param onlyOnce Specifies if the event should be triggered only once
  5796. */
  5797. constructor(
  5798. /** The frame for which the event is triggered **/
  5799. frame: number,
  5800. /** The event to perform when triggered **/
  5801. action: (currentFrame: number) => void,
  5802. /** Specifies if the event should be triggered only once**/
  5803. onlyOnce?: boolean | undefined);
  5804. /** @hidden */
  5805. _clone(): AnimationEvent;
  5806. }
  5807. }
  5808. declare module BABYLON {
  5809. /**
  5810. * Interface used to define a behavior
  5811. */
  5812. export interface Behavior<T> {
  5813. /** gets or sets behavior's name */
  5814. name: string;
  5815. /**
  5816. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5817. */
  5818. init(): void;
  5819. /**
  5820. * Called when the behavior is attached to a target
  5821. * @param target defines the target where the behavior is attached to
  5822. */
  5823. attach(target: T): void;
  5824. /**
  5825. * Called when the behavior is detached from its target
  5826. */
  5827. detach(): void;
  5828. }
  5829. /**
  5830. * Interface implemented by classes supporting behaviors
  5831. */
  5832. export interface IBehaviorAware<T> {
  5833. /**
  5834. * Attach a behavior
  5835. * @param behavior defines the behavior to attach
  5836. * @returns the current host
  5837. */
  5838. addBehavior(behavior: Behavior<T>): T;
  5839. /**
  5840. * Remove a behavior from the current object
  5841. * @param behavior defines the behavior to detach
  5842. * @returns the current host
  5843. */
  5844. removeBehavior(behavior: Behavior<T>): T;
  5845. /**
  5846. * Gets a behavior using its name to search
  5847. * @param name defines the name to search
  5848. * @returns the behavior or null if not found
  5849. */
  5850. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. /**
  5855. * Defines an array and its length.
  5856. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5857. */
  5858. export interface ISmartArrayLike<T> {
  5859. /**
  5860. * The data of the array.
  5861. */
  5862. data: Array<T>;
  5863. /**
  5864. * The active length of the array.
  5865. */
  5866. length: number;
  5867. }
  5868. /**
  5869. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5870. */
  5871. export class SmartArray<T> implements ISmartArrayLike<T> {
  5872. /**
  5873. * The full set of data from the array.
  5874. */
  5875. data: Array<T>;
  5876. /**
  5877. * The active length of the array.
  5878. */
  5879. length: number;
  5880. protected _id: number;
  5881. /**
  5882. * Instantiates a Smart Array.
  5883. * @param capacity defines the default capacity of the array.
  5884. */
  5885. constructor(capacity: number);
  5886. /**
  5887. * Pushes a value at the end of the active data.
  5888. * @param value defines the object to push in the array.
  5889. */
  5890. push(value: T): void;
  5891. /**
  5892. * Iterates over the active data and apply the lambda to them.
  5893. * @param func defines the action to apply on each value.
  5894. */
  5895. forEach(func: (content: T) => void): void;
  5896. /**
  5897. * Sorts the full sets of data.
  5898. * @param compareFn defines the comparison function to apply.
  5899. */
  5900. sort(compareFn: (a: T, b: T) => number): void;
  5901. /**
  5902. * Resets the active data to an empty array.
  5903. */
  5904. reset(): void;
  5905. /**
  5906. * Releases all the data from the array as well as the array.
  5907. */
  5908. dispose(): void;
  5909. /**
  5910. * Concats the active data with a given array.
  5911. * @param array defines the data to concatenate with.
  5912. */
  5913. concat(array: any): void;
  5914. /**
  5915. * Returns the position of a value in the active data.
  5916. * @param value defines the value to find the index for
  5917. * @returns the index if found in the active data otherwise -1
  5918. */
  5919. indexOf(value: T): number;
  5920. /**
  5921. * Returns whether an element is part of the active data.
  5922. * @param value defines the value to look for
  5923. * @returns true if found in the active data otherwise false
  5924. */
  5925. contains(value: T): boolean;
  5926. private static _GlobalId;
  5927. }
  5928. /**
  5929. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5930. * The data in this array can only be present once
  5931. */
  5932. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5933. private _duplicateId;
  5934. /**
  5935. * Pushes a value at the end of the active data.
  5936. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5937. * @param value defines the object to push in the array.
  5938. */
  5939. push(value: T): void;
  5940. /**
  5941. * Pushes a value at the end of the active data.
  5942. * If the data is already present, it won t be added again
  5943. * @param value defines the object to push in the array.
  5944. * @returns true if added false if it was already present
  5945. */
  5946. pushNoDuplicate(value: T): boolean;
  5947. /**
  5948. * Resets the active data to an empty array.
  5949. */
  5950. reset(): void;
  5951. /**
  5952. * Concats the active data with a given array.
  5953. * This ensures no dupplicate will be present in the result.
  5954. * @param array defines the data to concatenate with.
  5955. */
  5956. concatWithNoDuplicate(array: any): void;
  5957. }
  5958. }
  5959. declare module BABYLON {
  5960. /**
  5961. * @ignore
  5962. * This is a list of all the different input types that are available in the application.
  5963. * Fo instance: ArcRotateCameraGamepadInput...
  5964. */
  5965. export var CameraInputTypes: {};
  5966. /**
  5967. * This is the contract to implement in order to create a new input class.
  5968. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5969. */
  5970. export interface ICameraInput<TCamera extends Camera> {
  5971. /**
  5972. * Defines the camera the input is attached to.
  5973. */
  5974. camera: Nullable<TCamera>;
  5975. /**
  5976. * Gets the class name of the current intput.
  5977. * @returns the class name
  5978. */
  5979. getClassName(): string;
  5980. /**
  5981. * Get the friendly name associated with the input class.
  5982. * @returns the input friendly name
  5983. */
  5984. getSimpleName(): string;
  5985. /**
  5986. * Attach the input controls to a specific dom element to get the input from.
  5987. * @param element Defines the element the controls should be listened from
  5988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5989. */
  5990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5991. /**
  5992. * Detach the current controls from the specified dom element.
  5993. * @param element Defines the element to stop listening the inputs from
  5994. */
  5995. detachControl(element: Nullable<HTMLElement>): void;
  5996. /**
  5997. * Update the current camera state depending on the inputs that have been used this frame.
  5998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5999. */
  6000. checkInputs?: () => void;
  6001. }
  6002. /**
  6003. * Represents a map of input types to input instance or input index to input instance.
  6004. */
  6005. export interface CameraInputsMap<TCamera extends Camera> {
  6006. /**
  6007. * Accessor to the input by input type.
  6008. */
  6009. [name: string]: ICameraInput<TCamera>;
  6010. /**
  6011. * Accessor to the input by input index.
  6012. */
  6013. [idx: number]: ICameraInput<TCamera>;
  6014. }
  6015. /**
  6016. * This represents the input manager used within a camera.
  6017. * It helps dealing with all the different kind of input attached to a camera.
  6018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6019. */
  6020. export class CameraInputsManager<TCamera extends Camera> {
  6021. /**
  6022. * Defines the list of inputs attahed to the camera.
  6023. */
  6024. attached: CameraInputsMap<TCamera>;
  6025. /**
  6026. * Defines the dom element the camera is collecting inputs from.
  6027. * This is null if the controls have not been attached.
  6028. */
  6029. attachedElement: Nullable<HTMLElement>;
  6030. /**
  6031. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6032. */
  6033. noPreventDefault: boolean;
  6034. /**
  6035. * Defined the camera the input manager belongs to.
  6036. */
  6037. camera: TCamera;
  6038. /**
  6039. * Update the current camera state depending on the inputs that have been used this frame.
  6040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6041. */
  6042. checkInputs: () => void;
  6043. /**
  6044. * Instantiate a new Camera Input Manager.
  6045. * @param camera Defines the camera the input manager blongs to
  6046. */
  6047. constructor(camera: TCamera);
  6048. /**
  6049. * Add an input method to a camera
  6050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6051. * @param input camera input method
  6052. */
  6053. add(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Remove a specific input method from a camera
  6056. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6057. * @param inputToRemove camera input method
  6058. */
  6059. remove(inputToRemove: ICameraInput<TCamera>): void;
  6060. /**
  6061. * Remove a specific input type from a camera
  6062. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6063. * @param inputType the type of the input to remove
  6064. */
  6065. removeByType(inputType: string): void;
  6066. private _addCheckInputs;
  6067. /**
  6068. * Attach the input controls to the currently attached dom element to listen the events from.
  6069. * @param input Defines the input to attach
  6070. */
  6071. attachInput(input: ICameraInput<TCamera>): void;
  6072. /**
  6073. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6074. * @param element Defines the dom element to collect the events from
  6075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6076. */
  6077. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6078. /**
  6079. * Detach the current manager inputs controls from a specific dom element.
  6080. * @param element Defines the dom element to collect the events from
  6081. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6082. */
  6083. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6084. /**
  6085. * Rebuild the dynamic inputCheck function from the current list of
  6086. * defined inputs in the manager.
  6087. */
  6088. rebuildInputCheck(): void;
  6089. /**
  6090. * Remove all attached input methods from a camera
  6091. */
  6092. clear(): void;
  6093. /**
  6094. * Serialize the current input manager attached to a camera.
  6095. * This ensures than once parsed,
  6096. * the input associated to the camera will be identical to the current ones
  6097. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6098. */
  6099. serialize(serializedCamera: any): void;
  6100. /**
  6101. * Parses an input manager serialized JSON to restore the previous list of inputs
  6102. * and states associated to a camera.
  6103. * @param parsedCamera Defines the JSON to parse
  6104. */
  6105. parse(parsedCamera: any): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * Class used to store data that will be store in GPU memory
  6111. */
  6112. export class Buffer {
  6113. private _engine;
  6114. private _buffer;
  6115. /** @hidden */
  6116. _data: Nullable<DataArray>;
  6117. private _updatable;
  6118. private _instanced;
  6119. private _divisor;
  6120. /**
  6121. * Gets the byte stride.
  6122. */
  6123. readonly byteStride: number;
  6124. /**
  6125. * Constructor
  6126. * @param engine the engine
  6127. * @param data the data to use for this buffer
  6128. * @param updatable whether the data is updatable
  6129. * @param stride the stride (optional)
  6130. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6131. * @param instanced whether the buffer is instanced (optional)
  6132. * @param useBytes set to true if the stride in in bytes (optional)
  6133. * @param divisor sets an optional divisor for instances (1 by default)
  6134. */
  6135. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6136. /**
  6137. * Create a new VertexBuffer based on the current buffer
  6138. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6139. * @param offset defines offset in the buffer (0 by default)
  6140. * @param size defines the size in floats of attributes (position is 3 for instance)
  6141. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6142. * @param instanced defines if the vertex buffer contains indexed data
  6143. * @param useBytes defines if the offset and stride are in bytes *
  6144. * @param divisor sets an optional divisor for instances (1 by default)
  6145. * @returns the new vertex buffer
  6146. */
  6147. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6148. /**
  6149. * Gets a boolean indicating if the Buffer is updatable?
  6150. * @returns true if the buffer is updatable
  6151. */
  6152. isUpdatable(): boolean;
  6153. /**
  6154. * Gets current buffer's data
  6155. * @returns a DataArray or null
  6156. */
  6157. getData(): Nullable<DataArray>;
  6158. /**
  6159. * Gets underlying native buffer
  6160. * @returns underlying native buffer
  6161. */
  6162. getBuffer(): Nullable<DataBuffer>;
  6163. /**
  6164. * Gets the stride in float32 units (i.e. byte stride / 4).
  6165. * May not be an integer if the byte stride is not divisible by 4.
  6166. * DEPRECATED. Use byteStride instead.
  6167. * @returns the stride in float32 units
  6168. */
  6169. getStrideSize(): number;
  6170. /**
  6171. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6172. * @param data defines the data to store
  6173. */
  6174. create(data?: Nullable<DataArray>): void;
  6175. /** @hidden */
  6176. _rebuild(): void;
  6177. /**
  6178. * Update current buffer data
  6179. * @param data defines the data to store
  6180. */
  6181. update(data: DataArray): void;
  6182. /**
  6183. * Updates the data directly.
  6184. * @param data the new data
  6185. * @param offset the new offset
  6186. * @param vertexCount the vertex count (optional)
  6187. * @param useBytes set to true if the offset is in bytes
  6188. */
  6189. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6190. /**
  6191. * Release all resources
  6192. */
  6193. dispose(): void;
  6194. }
  6195. /**
  6196. * Specialized buffer used to store vertex data
  6197. */
  6198. export class VertexBuffer {
  6199. /** @hidden */
  6200. _buffer: Buffer;
  6201. private _kind;
  6202. private _size;
  6203. private _ownsBuffer;
  6204. private _instanced;
  6205. private _instanceDivisor;
  6206. /**
  6207. * The byte type.
  6208. */
  6209. static readonly BYTE: number;
  6210. /**
  6211. * The unsigned byte type.
  6212. */
  6213. static readonly UNSIGNED_BYTE: number;
  6214. /**
  6215. * The short type.
  6216. */
  6217. static readonly SHORT: number;
  6218. /**
  6219. * The unsigned short type.
  6220. */
  6221. static readonly UNSIGNED_SHORT: number;
  6222. /**
  6223. * The integer type.
  6224. */
  6225. static readonly INT: number;
  6226. /**
  6227. * The unsigned integer type.
  6228. */
  6229. static readonly UNSIGNED_INT: number;
  6230. /**
  6231. * The float type.
  6232. */
  6233. static readonly FLOAT: number;
  6234. /**
  6235. * Gets or sets the instance divisor when in instanced mode
  6236. */
  6237. instanceDivisor: number;
  6238. /**
  6239. * Gets the byte stride.
  6240. */
  6241. readonly byteStride: number;
  6242. /**
  6243. * Gets the byte offset.
  6244. */
  6245. readonly byteOffset: number;
  6246. /**
  6247. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6248. */
  6249. readonly normalized: boolean;
  6250. /**
  6251. * Gets the data type of each component in the array.
  6252. */
  6253. readonly type: number;
  6254. /**
  6255. * Constructor
  6256. * @param engine the engine
  6257. * @param data the data to use for this vertex buffer
  6258. * @param kind the vertex buffer kind
  6259. * @param updatable whether the data is updatable
  6260. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6261. * @param stride the stride (optional)
  6262. * @param instanced whether the buffer is instanced (optional)
  6263. * @param offset the offset of the data (optional)
  6264. * @param size the number of components (optional)
  6265. * @param type the type of the component (optional)
  6266. * @param normalized whether the data contains normalized data (optional)
  6267. * @param useBytes set to true if stride and offset are in bytes (optional)
  6268. * @param divisor defines the instance divisor to use (1 by default)
  6269. */
  6270. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6271. /** @hidden */
  6272. _rebuild(): void;
  6273. /**
  6274. * Returns the kind of the VertexBuffer (string)
  6275. * @returns a string
  6276. */
  6277. getKind(): string;
  6278. /**
  6279. * Gets a boolean indicating if the VertexBuffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Returns the offset as a multiple of the type byte length.
  6302. * DEPRECATED. Use byteOffset instead.
  6303. * @returns the offset in bytes
  6304. */
  6305. getOffset(): number;
  6306. /**
  6307. * Returns the number of components per vertex attribute (integer)
  6308. * @returns the size in float
  6309. */
  6310. getSize(): number;
  6311. /**
  6312. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6313. * @returns true if this buffer is instanced
  6314. */
  6315. getIsInstanced(): boolean;
  6316. /**
  6317. * Returns the instancing divisor, zero for non-instanced (integer).
  6318. * @returns a number
  6319. */
  6320. getInstanceDivisor(): number;
  6321. /**
  6322. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6323. * @param data defines the data to store
  6324. */
  6325. create(data?: DataArray): void;
  6326. /**
  6327. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6328. * This function will create a new buffer if the current one is not updatable
  6329. * @param data defines the data to store
  6330. */
  6331. update(data: DataArray): void;
  6332. /**
  6333. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6334. * Returns the directly updated WebGLBuffer.
  6335. * @param data the new data
  6336. * @param offset the new offset
  6337. * @param useBytes set to true if the offset is in bytes
  6338. */
  6339. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6340. /**
  6341. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6342. */
  6343. dispose(): void;
  6344. /**
  6345. * Enumerates each value of this vertex buffer as numbers.
  6346. * @param count the number of values to enumerate
  6347. * @param callback the callback function called for each value
  6348. */
  6349. forEach(count: number, callback: (value: number, index: number) => void): void;
  6350. /**
  6351. * Positions
  6352. */
  6353. static readonly PositionKind: string;
  6354. /**
  6355. * Normals
  6356. */
  6357. static readonly NormalKind: string;
  6358. /**
  6359. * Tangents
  6360. */
  6361. static readonly TangentKind: string;
  6362. /**
  6363. * Texture coordinates
  6364. */
  6365. static readonly UVKind: string;
  6366. /**
  6367. * Texture coordinates 2
  6368. */
  6369. static readonly UV2Kind: string;
  6370. /**
  6371. * Texture coordinates 3
  6372. */
  6373. static readonly UV3Kind: string;
  6374. /**
  6375. * Texture coordinates 4
  6376. */
  6377. static readonly UV4Kind: string;
  6378. /**
  6379. * Texture coordinates 5
  6380. */
  6381. static readonly UV5Kind: string;
  6382. /**
  6383. * Texture coordinates 6
  6384. */
  6385. static readonly UV6Kind: string;
  6386. /**
  6387. * Colors
  6388. */
  6389. static readonly ColorKind: string;
  6390. /**
  6391. * Matrix indices (for bones)
  6392. */
  6393. static readonly MatricesIndicesKind: string;
  6394. /**
  6395. * Matrix weights (for bones)
  6396. */
  6397. static readonly MatricesWeightsKind: string;
  6398. /**
  6399. * Additional matrix indices (for bones)
  6400. */
  6401. static readonly MatricesIndicesExtraKind: string;
  6402. /**
  6403. * Additional matrix weights (for bones)
  6404. */
  6405. static readonly MatricesWeightsExtraKind: string;
  6406. /**
  6407. * Deduces the stride given a kind.
  6408. * @param kind The kind string to deduce
  6409. * @returns The deduced stride
  6410. */
  6411. static DeduceStride(kind: string): number;
  6412. /**
  6413. * Gets the byte length of the given type.
  6414. * @param type the type
  6415. * @returns the number of bytes
  6416. */
  6417. static GetTypeByteLength(type: number): number;
  6418. /**
  6419. * Enumerates each value of the given parameters as numbers.
  6420. * @param data the data to enumerate
  6421. * @param byteOffset the byte offset of the data
  6422. * @param byteStride the byte stride of the data
  6423. * @param componentCount the number of components per element
  6424. * @param componentType the type of the component
  6425. * @param count the number of values to enumerate
  6426. * @param normalized whether the data is normalized
  6427. * @param callback the callback function called for each value
  6428. */
  6429. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6430. private static _GetFloatValue;
  6431. }
  6432. }
  6433. declare module BABYLON {
  6434. /**
  6435. * @hidden
  6436. */
  6437. export class IntersectionInfo {
  6438. bu: Nullable<number>;
  6439. bv: Nullable<number>;
  6440. distance: number;
  6441. faceId: number;
  6442. subMeshId: number;
  6443. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Represens a plane by the equation ax + by + cz + d = 0
  6449. */
  6450. export class Plane {
  6451. private static _TmpMatrix;
  6452. /**
  6453. * Normal of the plane (a,b,c)
  6454. */
  6455. normal: Vector3;
  6456. /**
  6457. * d component of the plane
  6458. */
  6459. d: number;
  6460. /**
  6461. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6462. * @param a a component of the plane
  6463. * @param b b component of the plane
  6464. * @param c c component of the plane
  6465. * @param d d component of the plane
  6466. */
  6467. constructor(a: number, b: number, c: number, d: number);
  6468. /**
  6469. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6470. */
  6471. asArray(): number[];
  6472. /**
  6473. * @returns a new plane copied from the current Plane.
  6474. */
  6475. clone(): Plane;
  6476. /**
  6477. * @returns the string "Plane".
  6478. */
  6479. getClassName(): string;
  6480. /**
  6481. * @returns the Plane hash code.
  6482. */
  6483. getHashCode(): number;
  6484. /**
  6485. * Normalize the current Plane in place.
  6486. * @returns the updated Plane.
  6487. */
  6488. normalize(): Plane;
  6489. /**
  6490. * Applies a transformation the plane and returns the result
  6491. * @param transformation the transformation matrix to be applied to the plane
  6492. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6493. */
  6494. transform(transformation: DeepImmutable<Matrix>): Plane;
  6495. /**
  6496. * Calcualtte the dot product between the point and the plane normal
  6497. * @param point point to calculate the dot product with
  6498. * @returns the dot product (float) of the point coordinates and the plane normal.
  6499. */
  6500. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6501. /**
  6502. * Updates the current Plane from the plane defined by the three given points.
  6503. * @param point1 one of the points used to contruct the plane
  6504. * @param point2 one of the points used to contruct the plane
  6505. * @param point3 one of the points used to contruct the plane
  6506. * @returns the updated Plane.
  6507. */
  6508. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6509. /**
  6510. * Checks if the plane is facing a given direction
  6511. * @param direction the direction to check if the plane is facing
  6512. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6513. * @returns True is the vector "direction" is the same side than the plane normal.
  6514. */
  6515. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6516. /**
  6517. * Calculates the distance to a point
  6518. * @param point point to calculate distance to
  6519. * @returns the signed distance (float) from the given point to the Plane.
  6520. */
  6521. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6522. /**
  6523. * Creates a plane from an array
  6524. * @param array the array to create a plane from
  6525. * @returns a new Plane from the given array.
  6526. */
  6527. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6528. /**
  6529. * Creates a plane from three points
  6530. * @param point1 point used to create the plane
  6531. * @param point2 point used to create the plane
  6532. * @param point3 point used to create the plane
  6533. * @returns a new Plane defined by the three given points.
  6534. */
  6535. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6536. /**
  6537. * Creates a plane from an origin point and a normal
  6538. * @param origin origin of the plane to be constructed
  6539. * @param normal normal of the plane to be constructed
  6540. * @returns a new Plane the normal vector to this plane at the given origin point.
  6541. * Note : the vector "normal" is updated because normalized.
  6542. */
  6543. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6544. /**
  6545. * Calculates the distance from a plane and a point
  6546. * @param origin origin of the plane to be constructed
  6547. * @param normal normal of the plane to be constructed
  6548. * @param point point to calculate distance to
  6549. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6550. */
  6551. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6552. }
  6553. }
  6554. declare module BABYLON {
  6555. /**
  6556. * Class used to store bounding sphere information
  6557. */
  6558. export class BoundingSphere {
  6559. /**
  6560. * Gets the center of the bounding sphere in local space
  6561. */
  6562. readonly center: Vector3;
  6563. /**
  6564. * Radius of the bounding sphere in local space
  6565. */
  6566. radius: number;
  6567. /**
  6568. * Gets the center of the bounding sphere in world space
  6569. */
  6570. readonly centerWorld: Vector3;
  6571. /**
  6572. * Radius of the bounding sphere in world space
  6573. */
  6574. radiusWorld: number;
  6575. /**
  6576. * Gets the minimum vector in local space
  6577. */
  6578. readonly minimum: Vector3;
  6579. /**
  6580. * Gets the maximum vector in local space
  6581. */
  6582. readonly maximum: Vector3;
  6583. private _worldMatrix;
  6584. private static readonly TmpVector3;
  6585. /**
  6586. * Creates a new bounding sphere
  6587. * @param min defines the minimum vector (in local space)
  6588. * @param max defines the maximum vector (in local space)
  6589. * @param worldMatrix defines the new world matrix
  6590. */
  6591. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6592. /**
  6593. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6594. * @param min defines the new minimum vector (in local space)
  6595. * @param max defines the new maximum vector (in local space)
  6596. * @param worldMatrix defines the new world matrix
  6597. */
  6598. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6599. /**
  6600. * Scale the current bounding sphere by applying a scale factor
  6601. * @param factor defines the scale factor to apply
  6602. * @returns the current bounding box
  6603. */
  6604. scale(factor: number): BoundingSphere;
  6605. /**
  6606. * Gets the world matrix of the bounding box
  6607. * @returns a matrix
  6608. */
  6609. getWorldMatrix(): DeepImmutable<Matrix>;
  6610. /** @hidden */
  6611. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6612. /**
  6613. * Tests if the bounding sphere is intersecting the frustum planes
  6614. * @param frustumPlanes defines the frustum planes to test
  6615. * @returns true if there is an intersection
  6616. */
  6617. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6618. /**
  6619. * Tests if the bounding sphere center is in between the frustum planes.
  6620. * Used for optimistic fast inclusion.
  6621. * @param frustumPlanes defines the frustum planes to test
  6622. * @returns true if the sphere center is in between the frustum planes
  6623. */
  6624. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6625. /**
  6626. * Tests if a point is inside the bounding sphere
  6627. * @param point defines the point to test
  6628. * @returns true if the point is inside the bounding sphere
  6629. */
  6630. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6631. /**
  6632. * Checks if two sphere intersct
  6633. * @param sphere0 sphere 0
  6634. * @param sphere1 sphere 1
  6635. * @returns true if the speres intersect
  6636. */
  6637. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6638. }
  6639. }
  6640. declare module BABYLON {
  6641. /**
  6642. * Class used to store bounding box information
  6643. */
  6644. export class BoundingBox implements ICullable {
  6645. /**
  6646. * Gets the 8 vectors representing the bounding box in local space
  6647. */
  6648. readonly vectors: Vector3[];
  6649. /**
  6650. * Gets the center of the bounding box in local space
  6651. */
  6652. readonly center: Vector3;
  6653. /**
  6654. * Gets the center of the bounding box in world space
  6655. */
  6656. readonly centerWorld: Vector3;
  6657. /**
  6658. * Gets the extend size in local space
  6659. */
  6660. readonly extendSize: Vector3;
  6661. /**
  6662. * Gets the extend size in world space
  6663. */
  6664. readonly extendSizeWorld: Vector3;
  6665. /**
  6666. * Gets the OBB (object bounding box) directions
  6667. */
  6668. readonly directions: Vector3[];
  6669. /**
  6670. * Gets the 8 vectors representing the bounding box in world space
  6671. */
  6672. readonly vectorsWorld: Vector3[];
  6673. /**
  6674. * Gets the minimum vector in world space
  6675. */
  6676. readonly minimumWorld: Vector3;
  6677. /**
  6678. * Gets the maximum vector in world space
  6679. */
  6680. readonly maximumWorld: Vector3;
  6681. /**
  6682. * Gets the minimum vector in local space
  6683. */
  6684. readonly minimum: Vector3;
  6685. /**
  6686. * Gets the maximum vector in local space
  6687. */
  6688. readonly maximum: Vector3;
  6689. private _worldMatrix;
  6690. private static readonly TmpVector3;
  6691. /**
  6692. * @hidden
  6693. */
  6694. _tag: number;
  6695. /**
  6696. * Creates a new bounding box
  6697. * @param min defines the minimum vector (in local space)
  6698. * @param max defines the maximum vector (in local space)
  6699. * @param worldMatrix defines the new world matrix
  6700. */
  6701. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6702. /**
  6703. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6709. /**
  6710. * Scale the current bounding box by applying a scale factor
  6711. * @param factor defines the scale factor to apply
  6712. * @returns the current bounding box
  6713. */
  6714. scale(factor: number): BoundingBox;
  6715. /**
  6716. * Gets the world matrix of the bounding box
  6717. * @returns a matrix
  6718. */
  6719. getWorldMatrix(): DeepImmutable<Matrix>;
  6720. /** @hidden */
  6721. _update(world: DeepImmutable<Matrix>): void;
  6722. /**
  6723. * Tests if the bounding box is intersecting the frustum planes
  6724. * @param frustumPlanes defines the frustum planes to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6728. /**
  6729. * Tests if the bounding box is entirely inside the frustum planes
  6730. * @param frustumPlanes defines the frustum planes to test
  6731. * @returns true if there is an inclusion
  6732. */
  6733. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6734. /**
  6735. * Tests if a point is inside the bounding box
  6736. * @param point defines the point to test
  6737. * @returns true if the point is inside the bounding box
  6738. */
  6739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6740. /**
  6741. * Tests if the bounding box intersects with a bounding sphere
  6742. * @param sphere defines the sphere to test
  6743. * @returns true if there is an intersection
  6744. */
  6745. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6746. /**
  6747. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6748. * @param min defines the min vector to use
  6749. * @param max defines the max vector to use
  6750. * @returns true if there is an intersection
  6751. */
  6752. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6753. /**
  6754. * Tests if two bounding boxes are intersections
  6755. * @param box0 defines the first box to test
  6756. * @param box1 defines the second box to test
  6757. * @returns true if there is an intersection
  6758. */
  6759. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6760. /**
  6761. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6762. * @param minPoint defines the minimum vector of the bounding box
  6763. * @param maxPoint defines the maximum vector of the bounding box
  6764. * @param sphereCenter defines the sphere center
  6765. * @param sphereRadius defines the sphere radius
  6766. * @returns true if there is an intersection
  6767. */
  6768. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6769. /**
  6770. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6771. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @return true if there is an inclusion
  6774. */
  6775. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6778. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @return true if there is an intersection
  6781. */
  6782. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. export class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /**
  6849. * Interface for cullable objects
  6850. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6851. */
  6852. export interface ICullable {
  6853. /**
  6854. * Checks if the object or part of the object is in the frustum
  6855. * @param frustumPlanes Camera near/planes
  6856. * @returns true if the object is in frustum otherwise false
  6857. */
  6858. isInFrustum(frustumPlanes: Plane[]): boolean;
  6859. /**
  6860. * Checks if a cullable object (mesh...) is in the camera frustum
  6861. * Unlike isInFrustum this cheks the full bounding box
  6862. * @param frustumPlanes Camera near/planes
  6863. * @returns true if the object is in frustum otherwise false
  6864. */
  6865. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6866. }
  6867. /**
  6868. * Info for a bounding data of a mesh
  6869. */
  6870. export class BoundingInfo implements ICullable {
  6871. /**
  6872. * Bounding box for the mesh
  6873. */
  6874. readonly boundingBox: BoundingBox;
  6875. /**
  6876. * Bounding sphere for the mesh
  6877. */
  6878. readonly boundingSphere: BoundingSphere;
  6879. private _isLocked;
  6880. private static readonly TmpVector3;
  6881. /**
  6882. * Constructs bounding info
  6883. * @param minimum min vector of the bounding box/sphere
  6884. * @param maximum max vector of the bounding box/sphere
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6888. /**
  6889. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6890. * @param min defines the new minimum vector (in local space)
  6891. * @param max defines the new maximum vector (in local space)
  6892. * @param worldMatrix defines the new world matrix
  6893. */
  6894. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6895. /**
  6896. * min vector of the bounding box/sphere
  6897. */
  6898. readonly minimum: Vector3;
  6899. /**
  6900. * max vector of the bounding box/sphere
  6901. */
  6902. readonly maximum: Vector3;
  6903. /**
  6904. * If the info is locked and won't be updated to avoid perf overhead
  6905. */
  6906. isLocked: boolean;
  6907. /**
  6908. * Updates the bounding sphere and box
  6909. * @param world world matrix to be used to update
  6910. */
  6911. update(world: DeepImmutable<Matrix>): void;
  6912. /**
  6913. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6914. * @param center New center of the bounding info
  6915. * @param extend New extend of the bounding info
  6916. * @returns the current bounding info
  6917. */
  6918. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6919. /**
  6920. * Scale the current bounding info by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding info
  6923. */
  6924. scale(factor: number): BoundingInfo;
  6925. /**
  6926. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6927. * @param frustumPlanes defines the frustum to test
  6928. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6929. * @returns true if the bounding info is in the frustum planes
  6930. */
  6931. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6932. /**
  6933. * Gets the world distance between the min and max points of the bounding box
  6934. */
  6935. readonly diagonalLength: number;
  6936. /**
  6937. * Checks if a cullable object (mesh...) is in the camera frustum
  6938. * Unlike isInFrustum this cheks the full bounding box
  6939. * @param frustumPlanes Camera near/planes
  6940. * @returns true if the object is in frustum otherwise false
  6941. */
  6942. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /** @hidden */
  6944. _checkCollision(collider: Collider): boolean;
  6945. /**
  6946. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6947. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6948. * @param point the point to check intersection with
  6949. * @returns if the point intersects
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6954. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6955. * @param boundingInfo the bounding info to check intersection with
  6956. * @param precise if the intersection should be done using OBB
  6957. * @returns if the bounding info intersects
  6958. */
  6959. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6960. }
  6961. }
  6962. declare module BABYLON {
  6963. /**
  6964. * Extracts minimum and maximum values from a list of indexed positions
  6965. * @param positions defines the positions to use
  6966. * @param indices defines the indices to the positions
  6967. * @param indexStart defines the start index
  6968. * @param indexCount defines the end index
  6969. * @param bias defines bias value to add to the result
  6970. * @return minimum and maximum values
  6971. */
  6972. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6973. minimum: Vector3;
  6974. maximum: Vector3;
  6975. };
  6976. /**
  6977. * Extracts minimum and maximum values from a list of positions
  6978. * @param positions defines the positions to use
  6979. * @param start defines the start index in the positions array
  6980. * @param count defines the number of positions to handle
  6981. * @param bias defines bias value to add to the result
  6982. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6983. * @return minimum and maximum values
  6984. */
  6985. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6986. minimum: Vector3;
  6987. maximum: Vector3;
  6988. };
  6989. }
  6990. declare module BABYLON {
  6991. /** @hidden */
  6992. export class WebGLDataBuffer extends DataBuffer {
  6993. private _buffer;
  6994. constructor(resource: WebGLBuffer);
  6995. readonly underlyingResource: any;
  6996. }
  6997. }
  6998. declare module BABYLON {
  6999. /** @hidden */
  7000. export class WebGLPipelineContext implements IPipelineContext {
  7001. engine: ThinEngine;
  7002. program: Nullable<WebGLProgram>;
  7003. context?: WebGLRenderingContext;
  7004. vertexShader?: WebGLShader;
  7005. fragmentShader?: WebGLShader;
  7006. isParallelCompiled: boolean;
  7007. onCompiled?: () => void;
  7008. transformFeedback?: WebGLTransformFeedback | null;
  7009. readonly isAsync: boolean;
  7010. readonly isReady: boolean;
  7011. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7012. }
  7013. }
  7014. declare module BABYLON {
  7015. interface ThinEngine {
  7016. /**
  7017. * Create an uniform buffer
  7018. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7019. * @param elements defines the content of the uniform buffer
  7020. * @returns the webGL uniform buffer
  7021. */
  7022. createUniformBuffer(elements: FloatArray): DataBuffer;
  7023. /**
  7024. * Create a dynamic uniform buffer
  7025. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7026. * @param elements defines the content of the uniform buffer
  7027. * @returns the webGL uniform buffer
  7028. */
  7029. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7030. /**
  7031. * Update an existing uniform buffer
  7032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7033. * @param uniformBuffer defines the target uniform buffer
  7034. * @param elements defines the content to update
  7035. * @param offset defines the offset in the uniform buffer where update should start
  7036. * @param count defines the size of the data to update
  7037. */
  7038. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7039. /**
  7040. * Bind an uniform buffer to the current webGL context
  7041. * @param buffer defines the buffer to bind
  7042. */
  7043. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7044. /**
  7045. * Bind a buffer to the current webGL context at a given location
  7046. * @param buffer defines the buffer to bind
  7047. * @param location defines the index where to bind the buffer
  7048. */
  7049. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7050. /**
  7051. * Bind a specific block at a given index in a specific shader program
  7052. * @param pipelineContext defines the pipeline context to use
  7053. * @param blockName defines the block name
  7054. * @param index defines the index where to bind the block
  7055. */
  7056. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Uniform buffer objects.
  7062. *
  7063. * Handles blocks of uniform on the GPU.
  7064. *
  7065. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7066. *
  7067. * For more information, please refer to :
  7068. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7069. */
  7070. export class UniformBuffer {
  7071. private _engine;
  7072. private _buffer;
  7073. private _data;
  7074. private _bufferData;
  7075. private _dynamic?;
  7076. private _uniformLocations;
  7077. private _uniformSizes;
  7078. private _uniformLocationPointer;
  7079. private _needSync;
  7080. private _noUBO;
  7081. private _currentEffect;
  7082. /** @hidden */
  7083. _alreadyBound: boolean;
  7084. private static _MAX_UNIFORM_SIZE;
  7085. private static _tempBuffer;
  7086. /**
  7087. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7088. * This is dynamic to allow compat with webgl 1 and 2.
  7089. * You will need to pass the name of the uniform as well as the value.
  7090. */
  7091. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7092. /**
  7093. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7094. * This is dynamic to allow compat with webgl 1 and 2.
  7095. * You will need to pass the name of the uniform as well as the value.
  7096. */
  7097. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7098. /**
  7099. * Lambda to Update a single float in a uniform buffer.
  7100. * This is dynamic to allow compat with webgl 1 and 2.
  7101. * You will need to pass the name of the uniform as well as the value.
  7102. */
  7103. updateFloat: (name: string, x: number) => void;
  7104. /**
  7105. * Lambda to Update a vec2 of float in a uniform buffer.
  7106. * This is dynamic to allow compat with webgl 1 and 2.
  7107. * You will need to pass the name of the uniform as well as the value.
  7108. */
  7109. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7110. /**
  7111. * Lambda to Update a vec3 of float in a uniform buffer.
  7112. * This is dynamic to allow compat with webgl 1 and 2.
  7113. * You will need to pass the name of the uniform as well as the value.
  7114. */
  7115. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7116. /**
  7117. * Lambda to Update a vec4 of float in a uniform buffer.
  7118. * This is dynamic to allow compat with webgl 1 and 2.
  7119. * You will need to pass the name of the uniform as well as the value.
  7120. */
  7121. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7122. /**
  7123. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7124. * This is dynamic to allow compat with webgl 1 and 2.
  7125. * You will need to pass the name of the uniform as well as the value.
  7126. */
  7127. updateMatrix: (name: string, mat: Matrix) => void;
  7128. /**
  7129. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7130. * This is dynamic to allow compat with webgl 1 and 2.
  7131. * You will need to pass the name of the uniform as well as the value.
  7132. */
  7133. updateVector3: (name: string, vector: Vector3) => void;
  7134. /**
  7135. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7136. * This is dynamic to allow compat with webgl 1 and 2.
  7137. * You will need to pass the name of the uniform as well as the value.
  7138. */
  7139. updateVector4: (name: string, vector: Vector4) => void;
  7140. /**
  7141. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7142. * This is dynamic to allow compat with webgl 1 and 2.
  7143. * You will need to pass the name of the uniform as well as the value.
  7144. */
  7145. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7146. /**
  7147. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7148. * This is dynamic to allow compat with webgl 1 and 2.
  7149. * You will need to pass the name of the uniform as well as the value.
  7150. */
  7151. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7152. /**
  7153. * Instantiates a new Uniform buffer objects.
  7154. *
  7155. * Handles blocks of uniform on the GPU.
  7156. *
  7157. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7158. *
  7159. * For more information, please refer to :
  7160. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7161. * @param engine Define the engine the buffer is associated with
  7162. * @param data Define the data contained in the buffer
  7163. * @param dynamic Define if the buffer is updatable
  7164. */
  7165. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7166. /**
  7167. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7168. * or just falling back on setUniformXXX calls.
  7169. */
  7170. readonly useUbo: boolean;
  7171. /**
  7172. * Indicates if the WebGL underlying uniform buffer is in sync
  7173. * with the javascript cache data.
  7174. */
  7175. readonly isSync: boolean;
  7176. /**
  7177. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7178. * Also, a dynamic UniformBuffer will disable cache verification and always
  7179. * update the underlying WebGL uniform buffer to the GPU.
  7180. * @returns if Dynamic, otherwise false
  7181. */
  7182. isDynamic(): boolean;
  7183. /**
  7184. * The data cache on JS side.
  7185. * @returns the underlying data as a float array
  7186. */
  7187. getData(): Float32Array;
  7188. /**
  7189. * The underlying WebGL Uniform buffer.
  7190. * @returns the webgl buffer
  7191. */
  7192. getBuffer(): Nullable<DataBuffer>;
  7193. /**
  7194. * std140 layout specifies how to align data within an UBO structure.
  7195. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7196. * for specs.
  7197. */
  7198. private _fillAlignment;
  7199. /**
  7200. * Adds an uniform in the buffer.
  7201. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7202. * for the layout to be correct !
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param size Data size, or data directly.
  7205. */
  7206. addUniform(name: string, size: number | number[]): void;
  7207. /**
  7208. * Adds a Matrix 4x4 to the uniform buffer.
  7209. * @param name Name of the uniform, as used in the uniform block in the shader.
  7210. * @param mat A 4x4 matrix.
  7211. */
  7212. addMatrix(name: string, mat: Matrix): void;
  7213. /**
  7214. * Adds a vec2 to the uniform buffer.
  7215. * @param name Name of the uniform, as used in the uniform block in the shader.
  7216. * @param x Define the x component value of the vec2
  7217. * @param y Define the y component value of the vec2
  7218. */
  7219. addFloat2(name: string, x: number, y: number): void;
  7220. /**
  7221. * Adds a vec3 to the uniform buffer.
  7222. * @param name Name of the uniform, as used in the uniform block in the shader.
  7223. * @param x Define the x component value of the vec3
  7224. * @param y Define the y component value of the vec3
  7225. * @param z Define the z component value of the vec3
  7226. */
  7227. addFloat3(name: string, x: number, y: number, z: number): void;
  7228. /**
  7229. * Adds a vec3 to the uniform buffer.
  7230. * @param name Name of the uniform, as used in the uniform block in the shader.
  7231. * @param color Define the vec3 from a Color
  7232. */
  7233. addColor3(name: string, color: Color3): void;
  7234. /**
  7235. * Adds a vec4 to the uniform buffer.
  7236. * @param name Name of the uniform, as used in the uniform block in the shader.
  7237. * @param color Define the rgb components from a Color
  7238. * @param alpha Define the a component of the vec4
  7239. */
  7240. addColor4(name: string, color: Color3, alpha: number): void;
  7241. /**
  7242. * Adds a vec3 to the uniform buffer.
  7243. * @param name Name of the uniform, as used in the uniform block in the shader.
  7244. * @param vector Define the vec3 components from a Vector
  7245. */
  7246. addVector3(name: string, vector: Vector3): void;
  7247. /**
  7248. * Adds a Matrix 3x3 to the uniform buffer.
  7249. * @param name Name of the uniform, as used in the uniform block in the shader.
  7250. */
  7251. addMatrix3x3(name: string): void;
  7252. /**
  7253. * Adds a Matrix 2x2 to the uniform buffer.
  7254. * @param name Name of the uniform, as used in the uniform block in the shader.
  7255. */
  7256. addMatrix2x2(name: string): void;
  7257. /**
  7258. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7259. */
  7260. create(): void;
  7261. /** @hidden */
  7262. _rebuild(): void;
  7263. /**
  7264. * Updates the WebGL Uniform Buffer on the GPU.
  7265. * If the `dynamic` flag is set to true, no cache comparison is done.
  7266. * Otherwise, the buffer will be updated only if the cache differs.
  7267. */
  7268. update(): void;
  7269. /**
  7270. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7271. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7272. * @param data Define the flattened data
  7273. * @param size Define the size of the data.
  7274. */
  7275. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7276. private _valueCache;
  7277. private _cacheMatrix;
  7278. private _updateMatrix3x3ForUniform;
  7279. private _updateMatrix3x3ForEffect;
  7280. private _updateMatrix2x2ForEffect;
  7281. private _updateMatrix2x2ForUniform;
  7282. private _updateFloatForEffect;
  7283. private _updateFloatForUniform;
  7284. private _updateFloat2ForEffect;
  7285. private _updateFloat2ForUniform;
  7286. private _updateFloat3ForEffect;
  7287. private _updateFloat3ForUniform;
  7288. private _updateFloat4ForEffect;
  7289. private _updateFloat4ForUniform;
  7290. private _updateMatrixForEffect;
  7291. private _updateMatrixForUniform;
  7292. private _updateVector3ForEffect;
  7293. private _updateVector3ForUniform;
  7294. private _updateVector4ForEffect;
  7295. private _updateVector4ForUniform;
  7296. private _updateColor3ForEffect;
  7297. private _updateColor3ForUniform;
  7298. private _updateColor4ForEffect;
  7299. private _updateColor4ForUniform;
  7300. /**
  7301. * Sets a sampler uniform on the effect.
  7302. * @param name Define the name of the sampler.
  7303. * @param texture Define the texture to set in the sampler
  7304. */
  7305. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7306. /**
  7307. * Directly updates the value of the uniform in the cache AND on the GPU.
  7308. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7309. * @param data Define the flattened data
  7310. */
  7311. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7312. /**
  7313. * Binds this uniform buffer to an effect.
  7314. * @param effect Define the effect to bind the buffer to
  7315. * @param name Name of the uniform block in the shader.
  7316. */
  7317. bindToEffect(effect: Effect, name: string): void;
  7318. /**
  7319. * Disposes the uniform buffer.
  7320. */
  7321. dispose(): void;
  7322. }
  7323. }
  7324. declare module BABYLON {
  7325. /**
  7326. * Enum that determines the text-wrapping mode to use.
  7327. */
  7328. export enum InspectableType {
  7329. /**
  7330. * Checkbox for booleans
  7331. */
  7332. Checkbox = 0,
  7333. /**
  7334. * Sliders for numbers
  7335. */
  7336. Slider = 1,
  7337. /**
  7338. * Vector3
  7339. */
  7340. Vector3 = 2,
  7341. /**
  7342. * Quaternions
  7343. */
  7344. Quaternion = 3,
  7345. /**
  7346. * Color3
  7347. */
  7348. Color3 = 4,
  7349. /**
  7350. * String
  7351. */
  7352. String = 5
  7353. }
  7354. /**
  7355. * Interface used to define custom inspectable properties.
  7356. * This interface is used by the inspector to display custom property grids
  7357. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7358. */
  7359. export interface IInspectable {
  7360. /**
  7361. * Gets the label to display
  7362. */
  7363. label: string;
  7364. /**
  7365. * Gets the name of the property to edit
  7366. */
  7367. propertyName: string;
  7368. /**
  7369. * Gets the type of the editor to use
  7370. */
  7371. type: InspectableType;
  7372. /**
  7373. * Gets the minimum value of the property when using in "slider" mode
  7374. */
  7375. min?: number;
  7376. /**
  7377. * Gets the maximum value of the property when using in "slider" mode
  7378. */
  7379. max?: number;
  7380. /**
  7381. * Gets the setp to use when using in "slider" mode
  7382. */
  7383. step?: number;
  7384. }
  7385. }
  7386. declare module BABYLON {
  7387. /**
  7388. * Class used to provide helper for timing
  7389. */
  7390. export class TimingTools {
  7391. /**
  7392. * Polyfill for setImmediate
  7393. * @param action defines the action to execute after the current execution block
  7394. */
  7395. static SetImmediate(action: () => void): void;
  7396. }
  7397. }
  7398. declare module BABYLON {
  7399. /**
  7400. * Class used to enable instatition of objects by class name
  7401. */
  7402. export class InstantiationTools {
  7403. /**
  7404. * Use this object to register external classes like custom textures or material
  7405. * to allow the laoders to instantiate them
  7406. */
  7407. static RegisteredExternalClasses: {
  7408. [key: string]: Object;
  7409. };
  7410. /**
  7411. * Tries to instantiate a new object from a given class name
  7412. * @param className defines the class name to instantiate
  7413. * @returns the new object or null if the system was not able to do the instantiation
  7414. */
  7415. static Instantiate(className: string): any;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * Define options used to create a depth texture
  7421. */
  7422. export class DepthTextureCreationOptions {
  7423. /** Specifies whether or not a stencil should be allocated in the texture */
  7424. generateStencil?: boolean;
  7425. /** Specifies whether or not bilinear filtering is enable on the texture */
  7426. bilinearFiltering?: boolean;
  7427. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7428. comparisonFunction?: number;
  7429. /** Specifies if the created texture is a cube texture */
  7430. isCube?: boolean;
  7431. }
  7432. }
  7433. declare module BABYLON {
  7434. interface ThinEngine {
  7435. /**
  7436. * Creates a depth stencil cube texture.
  7437. * This is only available in WebGL 2.
  7438. * @param size The size of face edge in the cube texture.
  7439. * @param options The options defining the cube texture.
  7440. * @returns The cube texture
  7441. */
  7442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7443. /**
  7444. * Creates a cube texture
  7445. * @param rootUrl defines the url where the files to load is located
  7446. * @param scene defines the current scene
  7447. * @param files defines the list of files to load (1 per face)
  7448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7449. * @param onLoad defines an optional callback raised when the texture is loaded
  7450. * @param onError defines an optional callback raised if there is an issue to load the texture
  7451. * @param format defines the format of the data
  7452. * @param forcedExtension defines the extension to use to pick the right loader
  7453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7458. * @returns the cube texture as an InternalTexture
  7459. */
  7460. 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;
  7461. /**
  7462. * Creates a cube texture
  7463. * @param rootUrl defines the url where the files to load is located
  7464. * @param scene defines the current scene
  7465. * @param files defines the list of files to load (1 per face)
  7466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7467. * @param onLoad defines an optional callback raised when the texture is loaded
  7468. * @param onError defines an optional callback raised if there is an issue to load the texture
  7469. * @param format defines the format of the data
  7470. * @param forcedExtension defines the extension to use to pick the right loader
  7471. * @returns the cube texture as an InternalTexture
  7472. */
  7473. 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;
  7474. /**
  7475. * Creates a cube texture
  7476. * @param rootUrl defines the url where the files to load is located
  7477. * @param scene defines the current scene
  7478. * @param files defines the list of files to load (1 per face)
  7479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7480. * @param onLoad defines an optional callback raised when the texture is loaded
  7481. * @param onError defines an optional callback raised if there is an issue to load the texture
  7482. * @param format defines the format of the data
  7483. * @param forcedExtension defines the extension to use to pick the right loader
  7484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7487. * @returns the cube texture as an InternalTexture
  7488. */
  7489. 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;
  7490. /** @hidden */
  7491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7492. /** @hidden */
  7493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7494. /** @hidden */
  7495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7496. /** @hidden */
  7497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7498. /**
  7499. * @hidden
  7500. */
  7501. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7502. }
  7503. }
  7504. declare module BABYLON {
  7505. /**
  7506. * Class for creating a cube texture
  7507. */
  7508. export class CubeTexture extends BaseTexture {
  7509. private _delayedOnLoad;
  7510. /**
  7511. * The url of the texture
  7512. */
  7513. url: string;
  7514. /**
  7515. * Gets or sets the center of the bounding box associated with the cube texture.
  7516. * It must define where the camera used to render the texture was set
  7517. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7518. */
  7519. boundingBoxPosition: Vector3;
  7520. private _boundingBoxSize;
  7521. /**
  7522. * Gets or sets the size of the bounding box associated with the cube texture
  7523. * When defined, the cubemap will switch to local mode
  7524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7525. * @example https://www.babylonjs-playground.com/#RNASML
  7526. */
  7527. /**
  7528. * Returns the bounding box size
  7529. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7530. */
  7531. boundingBoxSize: Vector3;
  7532. protected _rotationY: number;
  7533. /**
  7534. * Sets texture matrix rotation angle around Y axis in radians.
  7535. */
  7536. /**
  7537. * Gets texture matrix rotation angle around Y axis radians.
  7538. */
  7539. rotationY: number;
  7540. /**
  7541. * Are mip maps generated for this texture or not.
  7542. */
  7543. readonly noMipmap: boolean;
  7544. private _noMipmap;
  7545. private _files;
  7546. protected _forcedExtension: Nullable<string>;
  7547. private _extensions;
  7548. private _textureMatrix;
  7549. private _format;
  7550. private _createPolynomials;
  7551. /** @hidden */
  7552. _prefiltered: boolean;
  7553. /**
  7554. * Creates a cube texture from an array of image urls
  7555. * @param files defines an array of image urls
  7556. * @param scene defines the hosting scene
  7557. * @param noMipmap specifies if mip maps are not used
  7558. * @returns a cube texture
  7559. */
  7560. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7561. /**
  7562. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7563. * @param url defines the url of the prefiltered texture
  7564. * @param scene defines the scene the texture is attached to
  7565. * @param forcedExtension defines the extension of the file if different from the url
  7566. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7567. * @return the prefiltered texture
  7568. */
  7569. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7570. /**
  7571. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7572. * as prefiltered data.
  7573. * @param rootUrl defines the url of the texture or the root name of the six images
  7574. * @param scene defines the scene the texture is attached to
  7575. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7576. * @param noMipmap defines if mipmaps should be created or not
  7577. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7578. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7579. * @param onError defines a callback triggered in case of error during load
  7580. * @param format defines the internal format to use for the texture once loaded
  7581. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7582. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7583. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7584. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7585. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7586. * @return the cube texture
  7587. */
  7588. 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);
  7589. /**
  7590. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7591. */
  7592. readonly isPrefiltered: boolean;
  7593. /**
  7594. * Get the current class name of the texture useful for serialization or dynamic coding.
  7595. * @returns "CubeTexture"
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Update the url (and optional buffer) of this texture if url was null during construction.
  7600. * @param url the url of the texture
  7601. * @param forcedExtension defines the extension to use
  7602. * @param onLoad callback called when the texture is loaded (defaults to null)
  7603. */
  7604. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7605. /**
  7606. * Delays loading of the cube texture
  7607. * @param forcedExtension defines the extension to use
  7608. */
  7609. delayLoad(forcedExtension?: string): void;
  7610. /**
  7611. * Returns the reflection texture matrix
  7612. * @returns the reflection texture matrix
  7613. */
  7614. getReflectionTextureMatrix(): Matrix;
  7615. /**
  7616. * Sets the reflection texture matrix
  7617. * @param value Reflection texture matrix
  7618. */
  7619. setReflectionTextureMatrix(value: Matrix): void;
  7620. /**
  7621. * Parses text to create a cube texture
  7622. * @param parsedTexture define the serialized text to read from
  7623. * @param scene defines the hosting scene
  7624. * @param rootUrl defines the root url of the cube texture
  7625. * @returns a cube texture
  7626. */
  7627. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7628. /**
  7629. * Makes a clone, or deep copy, of the cube texture
  7630. * @returns a new cube texture
  7631. */
  7632. clone(): CubeTexture;
  7633. }
  7634. }
  7635. declare module BABYLON {
  7636. /**
  7637. * Manages the defines for the Material
  7638. */
  7639. export class MaterialDefines {
  7640. /** @hidden */
  7641. protected _keys: string[];
  7642. private _isDirty;
  7643. /** @hidden */
  7644. _renderId: number;
  7645. /** @hidden */
  7646. _areLightsDirty: boolean;
  7647. /** @hidden */
  7648. _areLightsDisposed: boolean;
  7649. /** @hidden */
  7650. _areAttributesDirty: boolean;
  7651. /** @hidden */
  7652. _areTexturesDirty: boolean;
  7653. /** @hidden */
  7654. _areFresnelDirty: boolean;
  7655. /** @hidden */
  7656. _areMiscDirty: boolean;
  7657. /** @hidden */
  7658. _areImageProcessingDirty: boolean;
  7659. /** @hidden */
  7660. _normals: boolean;
  7661. /** @hidden */
  7662. _uvs: boolean;
  7663. /** @hidden */
  7664. _needNormals: boolean;
  7665. /** @hidden */
  7666. _needUVs: boolean;
  7667. [id: string]: any;
  7668. /**
  7669. * Specifies if the material needs to be re-calculated
  7670. */
  7671. readonly isDirty: boolean;
  7672. /**
  7673. * Marks the material to indicate that it has been re-calculated
  7674. */
  7675. markAsProcessed(): void;
  7676. /**
  7677. * Marks the material to indicate that it needs to be re-calculated
  7678. */
  7679. markAsUnprocessed(): void;
  7680. /**
  7681. * Marks the material to indicate all of its defines need to be re-calculated
  7682. */
  7683. markAllAsDirty(): void;
  7684. /**
  7685. * Marks the material to indicate that image processing needs to be re-calculated
  7686. */
  7687. markAsImageProcessingDirty(): void;
  7688. /**
  7689. * Marks the material to indicate the lights need to be re-calculated
  7690. * @param disposed Defines whether the light is dirty due to dispose or not
  7691. */
  7692. markAsLightDirty(disposed?: boolean): void;
  7693. /**
  7694. * Marks the attribute state as changed
  7695. */
  7696. markAsAttributesDirty(): void;
  7697. /**
  7698. * Marks the texture state as changed
  7699. */
  7700. markAsTexturesDirty(): void;
  7701. /**
  7702. * Marks the fresnel state as changed
  7703. */
  7704. markAsFresnelDirty(): void;
  7705. /**
  7706. * Marks the misc state as changed
  7707. */
  7708. markAsMiscDirty(): void;
  7709. /**
  7710. * Rebuilds the material defines
  7711. */
  7712. rebuild(): void;
  7713. /**
  7714. * Specifies if two material defines are equal
  7715. * @param other - A material define instance to compare to
  7716. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7717. */
  7718. isEqual(other: MaterialDefines): boolean;
  7719. /**
  7720. * Clones this instance's defines to another instance
  7721. * @param other - material defines to clone values to
  7722. */
  7723. cloneTo(other: MaterialDefines): void;
  7724. /**
  7725. * Resets the material define values
  7726. */
  7727. reset(): void;
  7728. /**
  7729. * Converts the material define values to a string
  7730. * @returns - String of material define information
  7731. */
  7732. toString(): string;
  7733. }
  7734. }
  7735. declare module BABYLON {
  7736. /**
  7737. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7738. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7739. * 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;
  7740. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7741. */
  7742. export class ColorCurves {
  7743. private _dirty;
  7744. private _tempColor;
  7745. private _globalCurve;
  7746. private _highlightsCurve;
  7747. private _midtonesCurve;
  7748. private _shadowsCurve;
  7749. private _positiveCurve;
  7750. private _negativeCurve;
  7751. private _globalHue;
  7752. private _globalDensity;
  7753. private _globalSaturation;
  7754. private _globalExposure;
  7755. /**
  7756. * Gets the global Hue value.
  7757. * 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).
  7758. */
  7759. /**
  7760. * Sets the global Hue value.
  7761. * 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).
  7762. */
  7763. globalHue: number;
  7764. /**
  7765. * Gets the global Density value.
  7766. * 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.
  7767. * Values less than zero provide a filter of opposite hue.
  7768. */
  7769. /**
  7770. * Sets the global Density value.
  7771. * 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.
  7772. * Values less than zero provide a filter of opposite hue.
  7773. */
  7774. globalDensity: number;
  7775. /**
  7776. * Gets the global Saturation value.
  7777. * 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.
  7778. */
  7779. /**
  7780. * Sets the global Saturation value.
  7781. * 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.
  7782. */
  7783. globalSaturation: number;
  7784. /**
  7785. * Gets the global Exposure value.
  7786. * 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.
  7787. */
  7788. /**
  7789. * Sets the global Exposure value.
  7790. * 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.
  7791. */
  7792. globalExposure: number;
  7793. private _highlightsHue;
  7794. private _highlightsDensity;
  7795. private _highlightsSaturation;
  7796. private _highlightsExposure;
  7797. /**
  7798. * Gets the highlights Hue value.
  7799. * 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).
  7800. */
  7801. /**
  7802. * Sets the highlights Hue value.
  7803. * 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).
  7804. */
  7805. highlightsHue: number;
  7806. /**
  7807. * Gets the highlights Density value.
  7808. * 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.
  7809. * Values less than zero provide a filter of opposite hue.
  7810. */
  7811. /**
  7812. * Sets the highlights Density value.
  7813. * 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.
  7814. * Values less than zero provide a filter of opposite hue.
  7815. */
  7816. highlightsDensity: number;
  7817. /**
  7818. * Gets the highlights Saturation value.
  7819. * 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.
  7820. */
  7821. /**
  7822. * Sets the highlights Saturation value.
  7823. * 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.
  7824. */
  7825. highlightsSaturation: number;
  7826. /**
  7827. * Gets the highlights Exposure value.
  7828. * 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.
  7829. */
  7830. /**
  7831. * Sets the highlights Exposure value.
  7832. * 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.
  7833. */
  7834. highlightsExposure: number;
  7835. private _midtonesHue;
  7836. private _midtonesDensity;
  7837. private _midtonesSaturation;
  7838. private _midtonesExposure;
  7839. /**
  7840. * Gets the midtones Hue value.
  7841. * 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).
  7842. */
  7843. /**
  7844. * Sets the midtones Hue value.
  7845. * 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).
  7846. */
  7847. midtonesHue: number;
  7848. /**
  7849. * Gets the midtones Density value.
  7850. * 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.
  7851. * Values less than zero provide a filter of opposite hue.
  7852. */
  7853. /**
  7854. * Sets the midtones Density value.
  7855. * 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.
  7856. * Values less than zero provide a filter of opposite hue.
  7857. */
  7858. midtonesDensity: number;
  7859. /**
  7860. * Gets the midtones Saturation value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the midtones Saturation value.
  7865. * 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.
  7866. */
  7867. midtonesSaturation: number;
  7868. /**
  7869. * Gets the midtones Exposure value.
  7870. * 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.
  7871. */
  7872. /**
  7873. * Sets the midtones Exposure value.
  7874. * 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.
  7875. */
  7876. midtonesExposure: number;
  7877. private _shadowsHue;
  7878. private _shadowsDensity;
  7879. private _shadowsSaturation;
  7880. private _shadowsExposure;
  7881. /**
  7882. * Gets the shadows Hue value.
  7883. * 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).
  7884. */
  7885. /**
  7886. * Sets the shadows Hue value.
  7887. * 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).
  7888. */
  7889. shadowsHue: number;
  7890. /**
  7891. * Gets the shadows Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. /**
  7896. * Sets the shadows Density value.
  7897. * 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.
  7898. * Values less than zero provide a filter of opposite hue.
  7899. */
  7900. shadowsDensity: number;
  7901. /**
  7902. * Gets the shadows Saturation value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the shadows Saturation value.
  7907. * 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.
  7908. */
  7909. shadowsSaturation: number;
  7910. /**
  7911. * Gets the shadows Exposure value.
  7912. * 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.
  7913. */
  7914. /**
  7915. * Sets the shadows Exposure value.
  7916. * 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.
  7917. */
  7918. shadowsExposure: number;
  7919. /**
  7920. * Returns the class name
  7921. * @returns The class name
  7922. */
  7923. getClassName(): string;
  7924. /**
  7925. * Binds the color curves to the shader.
  7926. * @param colorCurves The color curve to bind
  7927. * @param effect The effect to bind to
  7928. * @param positiveUniform The positive uniform shader parameter
  7929. * @param neutralUniform The neutral uniform shader parameter
  7930. * @param negativeUniform The negative uniform shader parameter
  7931. */
  7932. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7933. /**
  7934. * Prepare the list of uniforms associated with the ColorCurves effects.
  7935. * @param uniformsList The list of uniforms used in the effect
  7936. */
  7937. static PrepareUniforms(uniformsList: string[]): void;
  7938. /**
  7939. * Returns color grading data based on a hue, density, saturation and exposure value.
  7940. * @param filterHue The hue of the color filter.
  7941. * @param filterDensity The density of the color filter.
  7942. * @param saturation The saturation.
  7943. * @param exposure The exposure.
  7944. * @param result The result data container.
  7945. */
  7946. private getColorGradingDataToRef;
  7947. /**
  7948. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7949. * @param value The input slider value in range [-100,100].
  7950. * @returns Adjusted value.
  7951. */
  7952. private static applyColorGradingSliderNonlinear;
  7953. /**
  7954. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7955. * @param hue The hue (H) input.
  7956. * @param saturation The saturation (S) input.
  7957. * @param brightness The brightness (B) input.
  7958. * @result An RGBA color represented as Vector4.
  7959. */
  7960. private static fromHSBToRef;
  7961. /**
  7962. * Returns a value clamped between min and max
  7963. * @param value The value to clamp
  7964. * @param min The minimum of value
  7965. * @param max The maximum of value
  7966. * @returns The clamped value.
  7967. */
  7968. private static clamp;
  7969. /**
  7970. * Clones the current color curve instance.
  7971. * @return The cloned curves
  7972. */
  7973. clone(): ColorCurves;
  7974. /**
  7975. * Serializes the current color curve instance to a json representation.
  7976. * @return a JSON representation
  7977. */
  7978. serialize(): any;
  7979. /**
  7980. * Parses the color curve from a json representation.
  7981. * @param source the JSON source to parse
  7982. * @return The parsed curves
  7983. */
  7984. static Parse(source: any): ColorCurves;
  7985. }
  7986. }
  7987. declare module BABYLON {
  7988. /**
  7989. * Interface to follow in your material defines to integrate easily the
  7990. * Image proccessing functions.
  7991. * @hidden
  7992. */
  7993. export interface IImageProcessingConfigurationDefines {
  7994. IMAGEPROCESSING: boolean;
  7995. VIGNETTE: boolean;
  7996. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7997. VIGNETTEBLENDMODEOPAQUE: boolean;
  7998. TONEMAPPING: boolean;
  7999. TONEMAPPING_ACES: boolean;
  8000. CONTRAST: boolean;
  8001. EXPOSURE: boolean;
  8002. COLORCURVES: boolean;
  8003. COLORGRADING: boolean;
  8004. COLORGRADING3D: boolean;
  8005. SAMPLER3DGREENDEPTH: boolean;
  8006. SAMPLER3DBGRMAP: boolean;
  8007. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8008. }
  8009. /**
  8010. * @hidden
  8011. */
  8012. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8013. IMAGEPROCESSING: boolean;
  8014. VIGNETTE: boolean;
  8015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8016. VIGNETTEBLENDMODEOPAQUE: boolean;
  8017. TONEMAPPING: boolean;
  8018. TONEMAPPING_ACES: boolean;
  8019. CONTRAST: boolean;
  8020. COLORCURVES: boolean;
  8021. COLORGRADING: boolean;
  8022. COLORGRADING3D: boolean;
  8023. SAMPLER3DGREENDEPTH: boolean;
  8024. SAMPLER3DBGRMAP: boolean;
  8025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8026. EXPOSURE: boolean;
  8027. constructor();
  8028. }
  8029. /**
  8030. * This groups together the common properties used for image processing either in direct forward pass
  8031. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8032. * or not.
  8033. */
  8034. export class ImageProcessingConfiguration {
  8035. /**
  8036. * Default tone mapping applied in BabylonJS.
  8037. */
  8038. static readonly TONEMAPPING_STANDARD: number;
  8039. /**
  8040. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8041. * to other engines rendering to increase portability.
  8042. */
  8043. static readonly TONEMAPPING_ACES: number;
  8044. /**
  8045. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8046. */
  8047. colorCurves: Nullable<ColorCurves>;
  8048. private _colorCurvesEnabled;
  8049. /**
  8050. * Gets wether the color curves effect is enabled.
  8051. */
  8052. /**
  8053. * Sets wether the color curves effect is enabled.
  8054. */
  8055. colorCurvesEnabled: boolean;
  8056. private _colorGradingTexture;
  8057. /**
  8058. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8059. */
  8060. /**
  8061. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8062. */
  8063. colorGradingTexture: Nullable<BaseTexture>;
  8064. private _colorGradingEnabled;
  8065. /**
  8066. * Gets wether the color grading effect is enabled.
  8067. */
  8068. /**
  8069. * Sets wether the color grading effect is enabled.
  8070. */
  8071. colorGradingEnabled: boolean;
  8072. private _colorGradingWithGreenDepth;
  8073. /**
  8074. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8075. */
  8076. /**
  8077. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8078. */
  8079. colorGradingWithGreenDepth: boolean;
  8080. private _colorGradingBGR;
  8081. /**
  8082. * Gets wether the color grading texture contains BGR values.
  8083. */
  8084. /**
  8085. * Sets wether the color grading texture contains BGR values.
  8086. */
  8087. colorGradingBGR: boolean;
  8088. /** @hidden */
  8089. _exposure: number;
  8090. /**
  8091. * Gets the Exposure used in the effect.
  8092. */
  8093. /**
  8094. * Sets the Exposure used in the effect.
  8095. */
  8096. exposure: number;
  8097. private _toneMappingEnabled;
  8098. /**
  8099. * Gets wether the tone mapping effect is enabled.
  8100. */
  8101. /**
  8102. * Sets wether the tone mapping effect is enabled.
  8103. */
  8104. toneMappingEnabled: boolean;
  8105. private _toneMappingType;
  8106. /**
  8107. * Gets the type of tone mapping effect.
  8108. */
  8109. /**
  8110. * Sets the type of tone mapping effect used in BabylonJS.
  8111. */
  8112. toneMappingType: number;
  8113. protected _contrast: number;
  8114. /**
  8115. * Gets the contrast used in the effect.
  8116. */
  8117. /**
  8118. * Sets the contrast used in the effect.
  8119. */
  8120. contrast: number;
  8121. /**
  8122. * Vignette stretch size.
  8123. */
  8124. vignetteStretch: number;
  8125. /**
  8126. * Vignette centre X Offset.
  8127. */
  8128. vignetteCentreX: number;
  8129. /**
  8130. * Vignette centre Y Offset.
  8131. */
  8132. vignetteCentreY: number;
  8133. /**
  8134. * Vignette weight or intensity of the vignette effect.
  8135. */
  8136. vignetteWeight: number;
  8137. /**
  8138. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8139. * if vignetteEnabled is set to true.
  8140. */
  8141. vignetteColor: Color4;
  8142. /**
  8143. * Camera field of view used by the Vignette effect.
  8144. */
  8145. vignetteCameraFov: number;
  8146. private _vignetteBlendMode;
  8147. /**
  8148. * Gets the vignette blend mode allowing different kind of effect.
  8149. */
  8150. /**
  8151. * Sets the vignette blend mode allowing different kind of effect.
  8152. */
  8153. vignetteBlendMode: number;
  8154. private _vignetteEnabled;
  8155. /**
  8156. * Gets wether the vignette effect is enabled.
  8157. */
  8158. /**
  8159. * Sets wether the vignette effect is enabled.
  8160. */
  8161. vignetteEnabled: boolean;
  8162. private _applyByPostProcess;
  8163. /**
  8164. * Gets wether the image processing is applied through a post process or not.
  8165. */
  8166. /**
  8167. * Sets wether the image processing is applied through a post process or not.
  8168. */
  8169. applyByPostProcess: boolean;
  8170. private _isEnabled;
  8171. /**
  8172. * Gets wether the image processing is enabled or not.
  8173. */
  8174. /**
  8175. * Sets wether the image processing is enabled or not.
  8176. */
  8177. isEnabled: boolean;
  8178. /**
  8179. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8180. */
  8181. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8182. /**
  8183. * Method called each time the image processing information changes requires to recompile the effect.
  8184. */
  8185. protected _updateParameters(): void;
  8186. /**
  8187. * Gets the current class name.
  8188. * @return "ImageProcessingConfiguration"
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * Prepare the list of uniforms associated with the Image Processing effects.
  8193. * @param uniforms The list of uniforms used in the effect
  8194. * @param defines the list of defines currently in use
  8195. */
  8196. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8197. /**
  8198. * Prepare the list of samplers associated with the Image Processing effects.
  8199. * @param samplersList The list of uniforms used in the effect
  8200. * @param defines the list of defines currently in use
  8201. */
  8202. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8203. /**
  8204. * Prepare the list of defines associated to the shader.
  8205. * @param defines the list of defines to complete
  8206. * @param forPostProcess Define if we are currently in post process mode or not
  8207. */
  8208. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8209. /**
  8210. * Returns true if all the image processing information are ready.
  8211. * @returns True if ready, otherwise, false
  8212. */
  8213. isReady(): boolean;
  8214. /**
  8215. * Binds the image processing to the shader.
  8216. * @param effect The effect to bind to
  8217. * @param overrideAspectRatio Override the aspect ratio of the effect
  8218. */
  8219. bind(effect: Effect, overrideAspectRatio?: number): void;
  8220. /**
  8221. * Clones the current image processing instance.
  8222. * @return The cloned image processing
  8223. */
  8224. clone(): ImageProcessingConfiguration;
  8225. /**
  8226. * Serializes the current image processing instance to a json representation.
  8227. * @return a JSON representation
  8228. */
  8229. serialize(): any;
  8230. /**
  8231. * Parses the image processing from a json representation.
  8232. * @param source the JSON source to parse
  8233. * @return The parsed image processing
  8234. */
  8235. static Parse(source: any): ImageProcessingConfiguration;
  8236. private static _VIGNETTEMODE_MULTIPLY;
  8237. private static _VIGNETTEMODE_OPAQUE;
  8238. /**
  8239. * Used to apply the vignette as a mix with the pixel color.
  8240. */
  8241. static readonly VIGNETTEMODE_MULTIPLY: number;
  8242. /**
  8243. * Used to apply the vignette as a replacement of the pixel color.
  8244. */
  8245. static readonly VIGNETTEMODE_OPAQUE: number;
  8246. }
  8247. }
  8248. declare module BABYLON {
  8249. /** @hidden */
  8250. export var postprocessVertexShader: {
  8251. name: string;
  8252. shader: string;
  8253. };
  8254. }
  8255. declare module BABYLON {
  8256. interface ThinEngine {
  8257. /**
  8258. * Creates a new render target texture
  8259. * @param size defines the size of the texture
  8260. * @param options defines the options used to create the texture
  8261. * @returns a new render target texture stored in an InternalTexture
  8262. */
  8263. createRenderTargetTexture(size: number | {
  8264. width: number;
  8265. height: number;
  8266. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8267. /**
  8268. * Creates a depth stencil texture.
  8269. * This is only available in WebGL 2 or with the depth texture extension available.
  8270. * @param size The size of face edge in the texture.
  8271. * @param options The options defining the texture.
  8272. * @returns The texture
  8273. */
  8274. createDepthStencilTexture(size: number | {
  8275. width: number;
  8276. height: number;
  8277. }, options: DepthTextureCreationOptions): InternalTexture;
  8278. /** @hidden */
  8279. _createDepthStencilTexture(size: number | {
  8280. width: number;
  8281. height: number;
  8282. }, options: DepthTextureCreationOptions): InternalTexture;
  8283. }
  8284. }
  8285. declare module BABYLON {
  8286. /** Defines supported spaces */
  8287. export enum Space {
  8288. /** Local (object) space */
  8289. LOCAL = 0,
  8290. /** World space */
  8291. WORLD = 1,
  8292. /** Bone space */
  8293. BONE = 2
  8294. }
  8295. /** Defines the 3 main axes */
  8296. export class Axis {
  8297. /** X axis */
  8298. static X: Vector3;
  8299. /** Y axis */
  8300. static Y: Vector3;
  8301. /** Z axis */
  8302. static Z: Vector3;
  8303. }
  8304. }
  8305. declare module BABYLON {
  8306. /**
  8307. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8308. * This is the base of the follow, arc rotate cameras and Free camera
  8309. * @see http://doc.babylonjs.com/features/cameras
  8310. */
  8311. export class TargetCamera extends Camera {
  8312. private static _RigCamTransformMatrix;
  8313. private static _TargetTransformMatrix;
  8314. private static _TargetFocalPoint;
  8315. /**
  8316. * Define the current direction the camera is moving to
  8317. */
  8318. cameraDirection: Vector3;
  8319. /**
  8320. * Define the current rotation the camera is rotating to
  8321. */
  8322. cameraRotation: Vector2;
  8323. /**
  8324. * When set, the up vector of the camera will be updated by the rotation of the camera
  8325. */
  8326. updateUpVectorFromRotation: boolean;
  8327. private _tmpQuaternion;
  8328. /**
  8329. * Define the current rotation of the camera
  8330. */
  8331. rotation: Vector3;
  8332. /**
  8333. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8334. */
  8335. rotationQuaternion: Quaternion;
  8336. /**
  8337. * Define the current speed of the camera
  8338. */
  8339. speed: number;
  8340. /**
  8341. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8342. * around all axis.
  8343. */
  8344. noRotationConstraint: boolean;
  8345. /**
  8346. * Define the current target of the camera as an object or a position.
  8347. */
  8348. lockedTarget: any;
  8349. /** @hidden */
  8350. _currentTarget: Vector3;
  8351. /** @hidden */
  8352. _initialFocalDistance: number;
  8353. /** @hidden */
  8354. _viewMatrix: Matrix;
  8355. /** @hidden */
  8356. _camMatrix: Matrix;
  8357. /** @hidden */
  8358. _cameraTransformMatrix: Matrix;
  8359. /** @hidden */
  8360. _cameraRotationMatrix: Matrix;
  8361. /** @hidden */
  8362. _referencePoint: Vector3;
  8363. /** @hidden */
  8364. _transformedReferencePoint: Vector3;
  8365. protected _globalCurrentTarget: Vector3;
  8366. protected _globalCurrentUpVector: Vector3;
  8367. /** @hidden */
  8368. _reset: () => void;
  8369. private _defaultUp;
  8370. /**
  8371. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8372. * This is the base of the follow, arc rotate cameras and Free camera
  8373. * @see http://doc.babylonjs.com/features/cameras
  8374. * @param name Defines the name of the camera in the scene
  8375. * @param position Defines the start position of the camera in the scene
  8376. * @param scene Defines the scene the camera belongs to
  8377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8378. */
  8379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8380. /**
  8381. * Gets the position in front of the camera at a given distance.
  8382. * @param distance The distance from the camera we want the position to be
  8383. * @returns the position
  8384. */
  8385. getFrontPosition(distance: number): Vector3;
  8386. /** @hidden */
  8387. _getLockedTargetPosition(): Nullable<Vector3>;
  8388. private _storedPosition;
  8389. private _storedRotation;
  8390. private _storedRotationQuaternion;
  8391. /**
  8392. * Store current camera state of the camera (fov, position, rotation, etc..)
  8393. * @returns the camera
  8394. */
  8395. storeState(): Camera;
  8396. /**
  8397. * Restored camera state. You must call storeState() first
  8398. * @returns whether it was successful or not
  8399. * @hidden
  8400. */
  8401. _restoreStateValues(): boolean;
  8402. /** @hidden */
  8403. _initCache(): void;
  8404. /** @hidden */
  8405. _updateCache(ignoreParentClass?: boolean): void;
  8406. /** @hidden */
  8407. _isSynchronizedViewMatrix(): boolean;
  8408. /** @hidden */
  8409. _computeLocalCameraSpeed(): number;
  8410. /**
  8411. * Defines the target the camera should look at.
  8412. * @param target Defines the new target as a Vector or a mesh
  8413. */
  8414. setTarget(target: Vector3): void;
  8415. /**
  8416. * Return the current target position of the camera. This value is expressed in local space.
  8417. * @returns the target position
  8418. */
  8419. getTarget(): Vector3;
  8420. /** @hidden */
  8421. _decideIfNeedsToMove(): boolean;
  8422. /** @hidden */
  8423. _updatePosition(): void;
  8424. /** @hidden */
  8425. _checkInputs(): void;
  8426. protected _updateCameraRotationMatrix(): void;
  8427. /**
  8428. * 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)
  8429. * @returns the current camera
  8430. */
  8431. private _rotateUpVectorWithCameraRotationMatrix;
  8432. private _cachedRotationZ;
  8433. private _cachedQuaternionRotationZ;
  8434. /** @hidden */
  8435. _getViewMatrix(): Matrix;
  8436. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8437. /**
  8438. * @hidden
  8439. */
  8440. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8441. /**
  8442. * @hidden
  8443. */
  8444. _updateRigCameras(): void;
  8445. private _getRigCamPositionAndTarget;
  8446. /**
  8447. * Gets the current object class name.
  8448. * @return the class name
  8449. */
  8450. getClassName(): string;
  8451. }
  8452. }
  8453. declare module BABYLON {
  8454. /**
  8455. * Gather the list of keyboard event types as constants.
  8456. */
  8457. export class KeyboardEventTypes {
  8458. /**
  8459. * The keydown event is fired when a key becomes active (pressed).
  8460. */
  8461. static readonly KEYDOWN: number;
  8462. /**
  8463. * The keyup event is fired when a key has been released.
  8464. */
  8465. static readonly KEYUP: number;
  8466. }
  8467. /**
  8468. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8469. */
  8470. export class KeyboardInfo {
  8471. /**
  8472. * Defines the type of event (KeyboardEventTypes)
  8473. */
  8474. type: number;
  8475. /**
  8476. * Defines the related dom event
  8477. */
  8478. event: KeyboardEvent;
  8479. /**
  8480. * Instantiates a new keyboard info.
  8481. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8482. * @param type Defines the type of event (KeyboardEventTypes)
  8483. * @param event Defines the related dom event
  8484. */
  8485. constructor(
  8486. /**
  8487. * Defines the type of event (KeyboardEventTypes)
  8488. */
  8489. type: number,
  8490. /**
  8491. * Defines the related dom event
  8492. */
  8493. event: KeyboardEvent);
  8494. }
  8495. /**
  8496. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8497. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8498. */
  8499. export class KeyboardInfoPre extends KeyboardInfo {
  8500. /**
  8501. * Defines the type of event (KeyboardEventTypes)
  8502. */
  8503. type: number;
  8504. /**
  8505. * Defines the related dom event
  8506. */
  8507. event: KeyboardEvent;
  8508. /**
  8509. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8510. */
  8511. skipOnPointerObservable: boolean;
  8512. /**
  8513. * Instantiates a new keyboard pre info.
  8514. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8515. * @param type Defines the type of event (KeyboardEventTypes)
  8516. * @param event Defines the related dom event
  8517. */
  8518. constructor(
  8519. /**
  8520. * Defines the type of event (KeyboardEventTypes)
  8521. */
  8522. type: number,
  8523. /**
  8524. * Defines the related dom event
  8525. */
  8526. event: KeyboardEvent);
  8527. }
  8528. }
  8529. declare module BABYLON {
  8530. /**
  8531. * Manage the keyboard inputs to control the movement of a free camera.
  8532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8533. */
  8534. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8535. /**
  8536. * Defines the camera the input is attached to.
  8537. */
  8538. camera: FreeCamera;
  8539. /**
  8540. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8541. */
  8542. keysUp: number[];
  8543. /**
  8544. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8545. */
  8546. keysDown: number[];
  8547. /**
  8548. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8549. */
  8550. keysLeft: number[];
  8551. /**
  8552. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8553. */
  8554. keysRight: number[];
  8555. private _keys;
  8556. private _onCanvasBlurObserver;
  8557. private _onKeyboardObserver;
  8558. private _engine;
  8559. private _scene;
  8560. /**
  8561. * Attach the input controls to a specific dom element to get the input from.
  8562. * @param element Defines the element the controls should be listened from
  8563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8564. */
  8565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8566. /**
  8567. * Detach the current controls from the specified dom element.
  8568. * @param element Defines the element to stop listening the inputs from
  8569. */
  8570. detachControl(element: Nullable<HTMLElement>): void;
  8571. /**
  8572. * Update the current camera state depending on the inputs that have been used this frame.
  8573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8574. */
  8575. checkInputs(): void;
  8576. /**
  8577. * Gets the class name of the current intput.
  8578. * @returns the class name
  8579. */
  8580. getClassName(): string;
  8581. /** @hidden */
  8582. _onLostFocus(): void;
  8583. /**
  8584. * Get the friendly name associated with the input class.
  8585. * @returns the input friendly name
  8586. */
  8587. getSimpleName(): string;
  8588. }
  8589. }
  8590. declare module BABYLON {
  8591. /**
  8592. * Interface describing all the common properties and methods a shadow light needs to implement.
  8593. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8594. * as well as binding the different shadow properties to the effects.
  8595. */
  8596. export interface IShadowLight extends Light {
  8597. /**
  8598. * The light id in the scene (used in scene.findLighById for instance)
  8599. */
  8600. id: string;
  8601. /**
  8602. * The position the shdow will be casted from.
  8603. */
  8604. position: Vector3;
  8605. /**
  8606. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8607. */
  8608. direction: Vector3;
  8609. /**
  8610. * The transformed position. Position of the light in world space taking parenting in account.
  8611. */
  8612. transformedPosition: Vector3;
  8613. /**
  8614. * The transformed direction. Direction of the light in world space taking parenting in account.
  8615. */
  8616. transformedDirection: Vector3;
  8617. /**
  8618. * The friendly name of the light in the scene.
  8619. */
  8620. name: string;
  8621. /**
  8622. * Defines the shadow projection clipping minimum z value.
  8623. */
  8624. shadowMinZ: number;
  8625. /**
  8626. * Defines the shadow projection clipping maximum z value.
  8627. */
  8628. shadowMaxZ: number;
  8629. /**
  8630. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8631. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8632. */
  8633. computeTransformedInformation(): boolean;
  8634. /**
  8635. * Gets the scene the light belongs to.
  8636. * @returns The scene
  8637. */
  8638. getScene(): Scene;
  8639. /**
  8640. * Callback defining a custom Projection Matrix Builder.
  8641. * This can be used to override the default projection matrix computation.
  8642. */
  8643. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8644. /**
  8645. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8646. * @param matrix The materix to updated with the projection information
  8647. * @param viewMatrix The transform matrix of the light
  8648. * @param renderList The list of mesh to render in the map
  8649. * @returns The current light
  8650. */
  8651. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8652. /**
  8653. * Gets the current depth scale used in ESM.
  8654. * @returns The scale
  8655. */
  8656. getDepthScale(): number;
  8657. /**
  8658. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8659. * @returns true if a cube texture needs to be use
  8660. */
  8661. needCube(): boolean;
  8662. /**
  8663. * Detects if the projection matrix requires to be recomputed this frame.
  8664. * @returns true if it requires to be recomputed otherwise, false.
  8665. */
  8666. needProjectionMatrixCompute(): boolean;
  8667. /**
  8668. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8669. */
  8670. forceProjectionMatrixCompute(): void;
  8671. /**
  8672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8675. */
  8676. getShadowDirection(faceIndex?: number): Vector3;
  8677. /**
  8678. * Gets the minZ used for shadow according to both the scene and the light.
  8679. * @param activeCamera The camera we are returning the min for
  8680. * @returns the depth min z
  8681. */
  8682. getDepthMinZ(activeCamera: Camera): number;
  8683. /**
  8684. * Gets the maxZ used for shadow according to both the scene and the light.
  8685. * @param activeCamera The camera we are returning the max for
  8686. * @returns the depth max z
  8687. */
  8688. getDepthMaxZ(activeCamera: Camera): number;
  8689. }
  8690. /**
  8691. * Base implementation IShadowLight
  8692. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8693. */
  8694. export abstract class ShadowLight extends Light implements IShadowLight {
  8695. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8696. protected _position: Vector3;
  8697. protected _setPosition(value: Vector3): void;
  8698. /**
  8699. * Sets the position the shadow will be casted from. Also use as the light position for both
  8700. * point and spot lights.
  8701. */
  8702. /**
  8703. * Sets the position the shadow will be casted from. Also use as the light position for both
  8704. * point and spot lights.
  8705. */
  8706. position: Vector3;
  8707. protected _direction: Vector3;
  8708. protected _setDirection(value: Vector3): void;
  8709. /**
  8710. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8711. * Also use as the light direction on spot and directional lights.
  8712. */
  8713. /**
  8714. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8715. * Also use as the light direction on spot and directional lights.
  8716. */
  8717. direction: Vector3;
  8718. private _shadowMinZ;
  8719. /**
  8720. * Gets the shadow projection clipping minimum z value.
  8721. */
  8722. /**
  8723. * Sets the shadow projection clipping minimum z value.
  8724. */
  8725. shadowMinZ: number;
  8726. private _shadowMaxZ;
  8727. /**
  8728. * Sets the shadow projection clipping maximum z value.
  8729. */
  8730. /**
  8731. * Gets the shadow projection clipping maximum z value.
  8732. */
  8733. shadowMaxZ: number;
  8734. /**
  8735. * Callback defining a custom Projection Matrix Builder.
  8736. * This can be used to override the default projection matrix computation.
  8737. */
  8738. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8739. /**
  8740. * The transformed position. Position of the light in world space taking parenting in account.
  8741. */
  8742. transformedPosition: Vector3;
  8743. /**
  8744. * The transformed direction. Direction of the light in world space taking parenting in account.
  8745. */
  8746. transformedDirection: Vector3;
  8747. private _needProjectionMatrixCompute;
  8748. /**
  8749. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8750. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8751. */
  8752. computeTransformedInformation(): boolean;
  8753. /**
  8754. * Return the depth scale used for the shadow map.
  8755. * @returns the depth scale.
  8756. */
  8757. getDepthScale(): number;
  8758. /**
  8759. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8760. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8761. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8762. */
  8763. getShadowDirection(faceIndex?: number): Vector3;
  8764. /**
  8765. * Returns the ShadowLight absolute position in the World.
  8766. * @returns the position vector in world space
  8767. */
  8768. getAbsolutePosition(): Vector3;
  8769. /**
  8770. * Sets the ShadowLight direction toward the passed target.
  8771. * @param target The point to target in local space
  8772. * @returns the updated ShadowLight direction
  8773. */
  8774. setDirectionToTarget(target: Vector3): Vector3;
  8775. /**
  8776. * Returns the light rotation in euler definition.
  8777. * @returns the x y z rotation in local space.
  8778. */
  8779. getRotation(): Vector3;
  8780. /**
  8781. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8782. * @returns true if a cube texture needs to be use
  8783. */
  8784. needCube(): boolean;
  8785. /**
  8786. * Detects if the projection matrix requires to be recomputed this frame.
  8787. * @returns true if it requires to be recomputed otherwise, false.
  8788. */
  8789. needProjectionMatrixCompute(): boolean;
  8790. /**
  8791. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8792. */
  8793. forceProjectionMatrixCompute(): void;
  8794. /** @hidden */
  8795. _initCache(): void;
  8796. /** @hidden */
  8797. _isSynchronized(): boolean;
  8798. /**
  8799. * Computes the world matrix of the node
  8800. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8801. * @returns the world matrix
  8802. */
  8803. computeWorldMatrix(force?: boolean): Matrix;
  8804. /**
  8805. * Gets the minZ used for shadow according to both the scene and the light.
  8806. * @param activeCamera The camera we are returning the min for
  8807. * @returns the depth min z
  8808. */
  8809. getDepthMinZ(activeCamera: Camera): number;
  8810. /**
  8811. * Gets the maxZ used for shadow according to both the scene and the light.
  8812. * @param activeCamera The camera we are returning the max for
  8813. * @returns the depth max z
  8814. */
  8815. getDepthMaxZ(activeCamera: Camera): number;
  8816. /**
  8817. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8818. * @param matrix The materix to updated with the projection information
  8819. * @param viewMatrix The transform matrix of the light
  8820. * @param renderList The list of mesh to render in the map
  8821. * @returns The current light
  8822. */
  8823. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8824. }
  8825. }
  8826. declare module BABYLON {
  8827. /**
  8828. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8829. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8830. */
  8831. export class EffectFallbacks implements IEffectFallbacks {
  8832. private _defines;
  8833. private _currentRank;
  8834. private _maxRank;
  8835. private _mesh;
  8836. /**
  8837. * Removes the fallback from the bound mesh.
  8838. */
  8839. unBindMesh(): void;
  8840. /**
  8841. * Adds a fallback on the specified property.
  8842. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8843. * @param define The name of the define in the shader
  8844. */
  8845. addFallback(rank: number, define: string): void;
  8846. /**
  8847. * Sets the mesh to use CPU skinning when needing to fallback.
  8848. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8849. * @param mesh The mesh to use the fallbacks.
  8850. */
  8851. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8852. /**
  8853. * Checks to see if more fallbacks are still availible.
  8854. */
  8855. readonly hasMoreFallbacks: boolean;
  8856. /**
  8857. * Removes the defines that should be removed when falling back.
  8858. * @param currentDefines defines the current define statements for the shader.
  8859. * @param effect defines the current effect we try to compile
  8860. * @returns The resulting defines with defines of the current rank removed.
  8861. */
  8862. reduce(currentDefines: string, effect: Effect): string;
  8863. }
  8864. }
  8865. declare module BABYLON {
  8866. /**
  8867. * "Static Class" containing the most commonly used helper while dealing with material for
  8868. * rendering purpose.
  8869. *
  8870. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8871. *
  8872. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8873. */
  8874. export class MaterialHelper {
  8875. /**
  8876. * Bind the current view position to an effect.
  8877. * @param effect The effect to be bound
  8878. * @param scene The scene the eyes position is used from
  8879. */
  8880. static BindEyePosition(effect: Effect, scene: Scene): void;
  8881. /**
  8882. * Helps preparing the defines values about the UVs in used in the effect.
  8883. * UVs are shared as much as we can accross channels in the shaders.
  8884. * @param texture The texture we are preparing the UVs for
  8885. * @param defines The defines to update
  8886. * @param key The channel key "diffuse", "specular"... used in the shader
  8887. */
  8888. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8889. /**
  8890. * Binds a texture matrix value to its corrsponding uniform
  8891. * @param texture The texture to bind the matrix for
  8892. * @param uniformBuffer The uniform buffer receivin the data
  8893. * @param key The channel key "diffuse", "specular"... used in the shader
  8894. */
  8895. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8896. /**
  8897. * Gets the current status of the fog (should it be enabled?)
  8898. * @param mesh defines the mesh to evaluate for fog support
  8899. * @param scene defines the hosting scene
  8900. * @returns true if fog must be enabled
  8901. */
  8902. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8903. /**
  8904. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8905. * @param mesh defines the current mesh
  8906. * @param scene defines the current scene
  8907. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8908. * @param pointsCloud defines if point cloud rendering has to be turned on
  8909. * @param fogEnabled defines if fog has to be turned on
  8910. * @param alphaTest defines if alpha testing has to be turned on
  8911. * @param defines defines the current list of defines
  8912. */
  8913. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8914. /**
  8915. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8916. * @param scene defines the current scene
  8917. * @param engine defines the current engine
  8918. * @param defines specifies the list of active defines
  8919. * @param useInstances defines if instances have to be turned on
  8920. * @param useClipPlane defines if clip plane have to be turned on
  8921. */
  8922. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8923. /**
  8924. * Prepares the defines for bones
  8925. * @param mesh The mesh containing the geometry data we will draw
  8926. * @param defines The defines to update
  8927. */
  8928. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8929. /**
  8930. * Prepares the defines for morph targets
  8931. * @param mesh The mesh containing the geometry data we will draw
  8932. * @param defines The defines to update
  8933. */
  8934. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8935. /**
  8936. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8937. * @param mesh The mesh containing the geometry data we will draw
  8938. * @param defines The defines to update
  8939. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8940. * @param useBones Precise whether bones should be used or not (override mesh info)
  8941. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8942. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8943. * @returns false if defines are considered not dirty and have not been checked
  8944. */
  8945. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8946. /**
  8947. * Prepares the defines related to multiview
  8948. * @param scene The scene we are intending to draw
  8949. * @param defines The defines to update
  8950. */
  8951. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8952. /**
  8953. * Prepares the defines related to the light information passed in parameter
  8954. * @param scene The scene we are intending to draw
  8955. * @param mesh The mesh the effect is compiling for
  8956. * @param light The light the effect is compiling for
  8957. * @param lightIndex The index of the light
  8958. * @param defines The defines to update
  8959. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8960. * @param state Defines the current state regarding what is needed (normals, etc...)
  8961. */
  8962. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8963. needNormals: boolean;
  8964. needRebuild: boolean;
  8965. shadowEnabled: boolean;
  8966. specularEnabled: boolean;
  8967. lightmapMode: boolean;
  8968. }): void;
  8969. /**
  8970. * Prepares the defines related to the light information passed in parameter
  8971. * @param scene The scene we are intending to draw
  8972. * @param mesh The mesh the effect is compiling for
  8973. * @param defines The defines to update
  8974. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8975. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8976. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8977. * @returns true if normals will be required for the rest of the effect
  8978. */
  8979. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8980. /**
  8981. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8982. * @param lightIndex defines the light index
  8983. * @param uniformsList The uniform list
  8984. * @param samplersList The sampler list
  8985. * @param projectedLightTexture defines if projected texture must be used
  8986. * @param uniformBuffersList defines an optional list of uniform buffers
  8987. */
  8988. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect
  8991. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8992. * @param samplersList The sampler list
  8993. * @param defines The defines helping in the list generation
  8994. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8995. */
  8996. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8997. /**
  8998. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8999. * @param defines The defines to update while falling back
  9000. * @param fallbacks The authorized effect fallbacks
  9001. * @param maxSimultaneousLights The maximum number of lights allowed
  9002. * @param rank the current rank of the Effect
  9003. * @returns The newly affected rank
  9004. */
  9005. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9006. private static _TmpMorphInfluencers;
  9007. /**
  9008. * Prepares the list of attributes required for morph targets according to the effect defines.
  9009. * @param attribs The current list of supported attribs
  9010. * @param mesh The mesh to prepare the morph targets attributes for
  9011. * @param influencers The number of influencers
  9012. */
  9013. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9014. /**
  9015. * Prepares the list of attributes required for morph targets according to the effect defines.
  9016. * @param attribs The current list of supported attribs
  9017. * @param mesh The mesh to prepare the morph targets attributes for
  9018. * @param defines The current Defines of the effect
  9019. */
  9020. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9021. /**
  9022. * Prepares the list of attributes required for bones according to the effect defines.
  9023. * @param attribs The current list of supported attribs
  9024. * @param mesh The mesh to prepare the bones attributes for
  9025. * @param defines The current Defines of the effect
  9026. * @param fallbacks The current efffect fallback strategy
  9027. */
  9028. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9029. /**
  9030. * Check and prepare the list of attributes required for instances according to the effect defines.
  9031. * @param attribs The current list of supported attribs
  9032. * @param defines The current MaterialDefines of the effect
  9033. */
  9034. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9035. /**
  9036. * Add the list of attributes required for instances to the attribs array.
  9037. * @param attribs The current list of supported attribs
  9038. */
  9039. static PushAttributesForInstances(attribs: string[]): void;
  9040. /**
  9041. * Binds the light information to the effect.
  9042. * @param light The light containing the generator
  9043. * @param effect The effect we are binding the data to
  9044. * @param lightIndex The light index in the effect used to render
  9045. */
  9046. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9047. /**
  9048. * Binds the lights information from the scene to the effect for the given mesh.
  9049. * @param light Light to bind
  9050. * @param lightIndex Light index
  9051. * @param scene The scene where the light belongs to
  9052. * @param effect The effect we are binding the data to
  9053. * @param useSpecular Defines if specular is supported
  9054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9055. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9056. */
  9057. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9058. /**
  9059. * Binds the lights information from the scene to the effect for the given mesh.
  9060. * @param scene The scene the lights belongs to
  9061. * @param mesh The mesh we are binding the information to render
  9062. * @param effect The effect we are binding the data to
  9063. * @param defines The generated defines for the effect
  9064. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9067. */
  9068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9069. private static _tempFogColor;
  9070. /**
  9071. * Binds the fog information from the scene to the effect for the given mesh.
  9072. * @param scene The scene the lights belongs to
  9073. * @param mesh The mesh we are binding the information to render
  9074. * @param effect The effect we are binding the data to
  9075. * @param linearSpace Defines if the fog effect is applied in linear space
  9076. */
  9077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9078. /**
  9079. * Binds the bones information from the mesh to the effect.
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. */
  9083. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9084. /**
  9085. * Binds the morph targets information from the mesh to the effect.
  9086. * @param abstractMesh The mesh we are binding the information to render
  9087. * @param effect The effect we are binding the data to
  9088. */
  9089. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9090. /**
  9091. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9092. * @param defines The generated defines used in the effect
  9093. * @param effect The effect we are binding the data to
  9094. * @param scene The scene we are willing to render with logarithmic scale for
  9095. */
  9096. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9097. /**
  9098. * Binds the clip plane information from the scene to the effect.
  9099. * @param scene The scene the clip plane information are extracted from
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindClipPlane(effect: Effect, scene: Scene): void;
  9103. }
  9104. }
  9105. declare module BABYLON {
  9106. /** @hidden */
  9107. export var packingFunctions: {
  9108. name: string;
  9109. shader: string;
  9110. };
  9111. }
  9112. declare module BABYLON {
  9113. /** @hidden */
  9114. export var shadowMapPixelShader: {
  9115. name: string;
  9116. shader: string;
  9117. };
  9118. }
  9119. declare module BABYLON {
  9120. /** @hidden */
  9121. export var bonesDeclaration: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module BABYLON {
  9127. /** @hidden */
  9128. export var morphTargetsVertexGlobalDeclaration: {
  9129. name: string;
  9130. shader: string;
  9131. };
  9132. }
  9133. declare module BABYLON {
  9134. /** @hidden */
  9135. export var morphTargetsVertexDeclaration: {
  9136. name: string;
  9137. shader: string;
  9138. };
  9139. }
  9140. declare module BABYLON {
  9141. /** @hidden */
  9142. export var instancesDeclaration: {
  9143. name: string;
  9144. shader: string;
  9145. };
  9146. }
  9147. declare module BABYLON {
  9148. /** @hidden */
  9149. export var helperFunctions: {
  9150. name: string;
  9151. shader: string;
  9152. };
  9153. }
  9154. declare module BABYLON {
  9155. /** @hidden */
  9156. export var morphTargetsVertex: {
  9157. name: string;
  9158. shader: string;
  9159. };
  9160. }
  9161. declare module BABYLON {
  9162. /** @hidden */
  9163. export var instancesVertex: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module BABYLON {
  9169. /** @hidden */
  9170. export var bonesVertex: {
  9171. name: string;
  9172. shader: string;
  9173. };
  9174. }
  9175. declare module BABYLON {
  9176. /** @hidden */
  9177. export var shadowMapVertexShader: {
  9178. name: string;
  9179. shader: string;
  9180. };
  9181. }
  9182. declare module BABYLON {
  9183. /** @hidden */
  9184. export var depthBoxBlurPixelShader: {
  9185. name: string;
  9186. shader: string;
  9187. };
  9188. }
  9189. declare module BABYLON {
  9190. /**
  9191. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9192. */
  9193. export interface ICustomShaderOptions {
  9194. /**
  9195. * Gets or sets the custom shader name to use
  9196. */
  9197. shaderName: string;
  9198. /**
  9199. * The list of attribute names used in the shader
  9200. */
  9201. attributes?: string[];
  9202. /**
  9203. * The list of unifrom names used in the shader
  9204. */
  9205. uniforms?: string[];
  9206. /**
  9207. * The list of sampler names used in the shader
  9208. */
  9209. samplers?: string[];
  9210. /**
  9211. * The list of defines used in the shader
  9212. */
  9213. defines?: string[];
  9214. }
  9215. /**
  9216. * Interface to implement to create a shadow generator compatible with BJS.
  9217. */
  9218. export interface IShadowGenerator {
  9219. /**
  9220. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9221. * @returns The render target texture if present otherwise, null
  9222. */
  9223. getShadowMap(): Nullable<RenderTargetTexture>;
  9224. /**
  9225. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9226. * @returns The render target texture if the shadow map is present otherwise, null
  9227. */
  9228. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9229. /**
  9230. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9231. * @param subMesh The submesh we want to render in the shadow map
  9232. * @param useInstances Defines wether will draw in the map using instances
  9233. * @returns true if ready otherwise, false
  9234. */
  9235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9236. /**
  9237. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9238. * @param defines Defines of the material we want to update
  9239. * @param lightIndex Index of the light in the enabled light list of the material
  9240. */
  9241. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9242. /**
  9243. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9244. * defined in the generator but impacting the effect).
  9245. * It implies the unifroms available on the materials are the standard BJS ones.
  9246. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9247. * @param effect The effect we are binfing the information for
  9248. */
  9249. bindShadowLight(lightIndex: string, effect: Effect): void;
  9250. /**
  9251. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9252. * (eq to shadow prjection matrix * light transform matrix)
  9253. * @returns The transform matrix used to create the shadow map
  9254. */
  9255. getTransformMatrix(): Matrix;
  9256. /**
  9257. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9258. * Cube and 2D textures for instance.
  9259. */
  9260. recreateShadowMap(): void;
  9261. /**
  9262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9263. * @param onCompiled Callback triggered at the and of the effects compilation
  9264. * @param options Sets of optional options forcing the compilation with different modes
  9265. */
  9266. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9267. useInstances: boolean;
  9268. }>): void;
  9269. /**
  9270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9271. * @param options Sets of optional options forcing the compilation with different modes
  9272. * @returns A promise that resolves when the compilation completes
  9273. */
  9274. forceCompilationAsync(options?: Partial<{
  9275. useInstances: boolean;
  9276. }>): Promise<void>;
  9277. /**
  9278. * Serializes the shadow generator setup to a json object.
  9279. * @returns The serialized JSON object
  9280. */
  9281. serialize(): any;
  9282. /**
  9283. * Disposes the Shadow map and related Textures and effects.
  9284. */
  9285. dispose(): void;
  9286. }
  9287. /**
  9288. * Default implementation IShadowGenerator.
  9289. * This is the main object responsible of generating shadows in the framework.
  9290. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9291. */
  9292. export class ShadowGenerator implements IShadowGenerator {
  9293. /**
  9294. * Shadow generator mode None: no filtering applied.
  9295. */
  9296. static readonly FILTER_NONE: number;
  9297. /**
  9298. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9299. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9300. */
  9301. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9302. /**
  9303. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9304. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9305. */
  9306. static readonly FILTER_POISSONSAMPLING: number;
  9307. /**
  9308. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9309. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9310. */
  9311. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9312. /**
  9313. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9314. * edge artifacts on steep falloff.
  9315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9316. */
  9317. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9318. /**
  9319. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9320. * edge artifacts on steep falloff.
  9321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9322. */
  9323. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9324. /**
  9325. * Shadow generator mode PCF: Percentage Closer Filtering
  9326. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9327. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9328. */
  9329. static readonly FILTER_PCF: number;
  9330. /**
  9331. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9333. * Contact Hardening
  9334. */
  9335. static readonly FILTER_PCSS: number;
  9336. /**
  9337. * Reserved for PCF and PCSS
  9338. * Highest Quality.
  9339. *
  9340. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9341. *
  9342. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9343. */
  9344. static readonly QUALITY_HIGH: number;
  9345. /**
  9346. * Reserved for PCF and PCSS
  9347. * Good tradeoff for quality/perf cross devices
  9348. *
  9349. * Execute PCF on a 3*3 kernel.
  9350. *
  9351. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9352. */
  9353. static readonly QUALITY_MEDIUM: number;
  9354. /**
  9355. * Reserved for PCF and PCSS
  9356. * The lowest quality but the fastest.
  9357. *
  9358. * Execute PCF on a 1*1 kernel.
  9359. *
  9360. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9361. */
  9362. static readonly QUALITY_LOW: number;
  9363. /** Gets or sets the custom shader name to use */
  9364. customShaderOptions: ICustomShaderOptions;
  9365. /**
  9366. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9367. */
  9368. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9369. /**
  9370. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9371. */
  9372. onAfterShadowMapRenderObservable: Observable<Effect>;
  9373. /**
  9374. * Observable triggered before a mesh is rendered in the shadow map.
  9375. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9376. */
  9377. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9378. /**
  9379. * Observable triggered after a mesh is rendered in the shadow map.
  9380. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9381. */
  9382. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9383. private _bias;
  9384. /**
  9385. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9386. */
  9387. /**
  9388. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9389. */
  9390. bias: number;
  9391. private _normalBias;
  9392. /**
  9393. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9394. */
  9395. /**
  9396. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9397. */
  9398. normalBias: number;
  9399. private _blurBoxOffset;
  9400. /**
  9401. * Gets the blur box offset: offset applied during the blur pass.
  9402. * Only useful if useKernelBlur = false
  9403. */
  9404. /**
  9405. * Sets the blur box offset: offset applied during the blur pass.
  9406. * Only useful if useKernelBlur = false
  9407. */
  9408. blurBoxOffset: number;
  9409. private _blurScale;
  9410. /**
  9411. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9412. * 2 means half of the size.
  9413. */
  9414. /**
  9415. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9416. * 2 means half of the size.
  9417. */
  9418. blurScale: number;
  9419. private _blurKernel;
  9420. /**
  9421. * Gets the blur kernel: kernel size of the blur pass.
  9422. * Only useful if useKernelBlur = true
  9423. */
  9424. /**
  9425. * Sets the blur kernel: kernel size of the blur pass.
  9426. * Only useful if useKernelBlur = true
  9427. */
  9428. blurKernel: number;
  9429. private _useKernelBlur;
  9430. /**
  9431. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9432. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9433. */
  9434. /**
  9435. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9436. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9437. */
  9438. useKernelBlur: boolean;
  9439. private _depthScale;
  9440. /**
  9441. * Gets the depth scale used in ESM mode.
  9442. */
  9443. /**
  9444. * Sets the depth scale used in ESM mode.
  9445. * This can override the scale stored on the light.
  9446. */
  9447. depthScale: number;
  9448. private _filter;
  9449. /**
  9450. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9451. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9452. */
  9453. /**
  9454. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9455. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9456. */
  9457. filter: number;
  9458. /**
  9459. * Gets if the current filter is set to Poisson Sampling.
  9460. */
  9461. /**
  9462. * Sets the current filter to Poisson Sampling.
  9463. */
  9464. usePoissonSampling: boolean;
  9465. /**
  9466. * Gets if the current filter is set to ESM.
  9467. */
  9468. /**
  9469. * Sets the current filter is to ESM.
  9470. */
  9471. useExponentialShadowMap: boolean;
  9472. /**
  9473. * Gets if the current filter is set to filtered ESM.
  9474. */
  9475. /**
  9476. * Gets if the current filter is set to filtered ESM.
  9477. */
  9478. useBlurExponentialShadowMap: boolean;
  9479. /**
  9480. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9481. * exponential to prevent steep falloff artifacts).
  9482. */
  9483. /**
  9484. * Sets the current filter to "close ESM" (using the inverse of the
  9485. * exponential to prevent steep falloff artifacts).
  9486. */
  9487. useCloseExponentialShadowMap: boolean;
  9488. /**
  9489. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9490. * exponential to prevent steep falloff artifacts).
  9491. */
  9492. /**
  9493. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9494. * exponential to prevent steep falloff artifacts).
  9495. */
  9496. useBlurCloseExponentialShadowMap: boolean;
  9497. /**
  9498. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9499. */
  9500. /**
  9501. * Sets the current filter to "PCF" (percentage closer filtering).
  9502. */
  9503. usePercentageCloserFiltering: boolean;
  9504. private _filteringQuality;
  9505. /**
  9506. * Gets the PCF or PCSS Quality.
  9507. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9508. */
  9509. /**
  9510. * Sets the PCF or PCSS Quality.
  9511. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9512. */
  9513. filteringQuality: number;
  9514. /**
  9515. * Gets if the current filter is set to "PCSS" (contact hardening).
  9516. */
  9517. /**
  9518. * Sets the current filter to "PCSS" (contact hardening).
  9519. */
  9520. useContactHardeningShadow: boolean;
  9521. private _contactHardeningLightSizeUVRatio;
  9522. /**
  9523. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9524. * Using a ratio helps keeping shape stability independently of the map size.
  9525. *
  9526. * It does not account for the light projection as it was having too much
  9527. * instability during the light setup or during light position changes.
  9528. *
  9529. * Only valid if useContactHardeningShadow is true.
  9530. */
  9531. /**
  9532. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9533. * Using a ratio helps keeping shape stability independently of the map size.
  9534. *
  9535. * It does not account for the light projection as it was having too much
  9536. * instability during the light setup or during light position changes.
  9537. *
  9538. * Only valid if useContactHardeningShadow is true.
  9539. */
  9540. contactHardeningLightSizeUVRatio: number;
  9541. private _darkness;
  9542. /** Gets or sets the actual darkness of a shadow */
  9543. darkness: number;
  9544. /**
  9545. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9546. * 0 means strongest and 1 would means no shadow.
  9547. * @returns the darkness.
  9548. */
  9549. getDarkness(): number;
  9550. /**
  9551. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9552. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9553. * @returns the shadow generator allowing fluent coding.
  9554. */
  9555. setDarkness(darkness: number): ShadowGenerator;
  9556. private _transparencyShadow;
  9557. /** Gets or sets the ability to have transparent shadow */
  9558. transparencyShadow: boolean;
  9559. /**
  9560. * Sets the ability to have transparent shadow (boolean).
  9561. * @param transparent True if transparent else False
  9562. * @returns the shadow generator allowing fluent coding
  9563. */
  9564. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9565. private _shadowMap;
  9566. private _shadowMap2;
  9567. /**
  9568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9569. * @returns The render target texture if present otherwise, null
  9570. */
  9571. getShadowMap(): Nullable<RenderTargetTexture>;
  9572. /**
  9573. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9574. * @returns The render target texture if the shadow map is present otherwise, null
  9575. */
  9576. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9577. /**
  9578. * Gets the class name of that object
  9579. * @returns "ShadowGenerator"
  9580. */
  9581. getClassName(): string;
  9582. /**
  9583. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9584. * @param mesh Mesh to add
  9585. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9586. * @returns the Shadow Generator itself
  9587. */
  9588. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9589. /**
  9590. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9591. * @param mesh Mesh to remove
  9592. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9593. * @returns the Shadow Generator itself
  9594. */
  9595. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9596. /**
  9597. * Controls the extent to which the shadows fade out at the edge of the frustum
  9598. * Used only by directionals and spots
  9599. */
  9600. frustumEdgeFalloff: number;
  9601. private _light;
  9602. /**
  9603. * Returns the associated light object.
  9604. * @returns the light generating the shadow
  9605. */
  9606. getLight(): IShadowLight;
  9607. /**
  9608. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9609. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9610. * It might on the other hand introduce peter panning.
  9611. */
  9612. forceBackFacesOnly: boolean;
  9613. private _scene;
  9614. private _lightDirection;
  9615. private _effect;
  9616. private _viewMatrix;
  9617. private _projectionMatrix;
  9618. private _transformMatrix;
  9619. private _cachedPosition;
  9620. private _cachedDirection;
  9621. private _cachedDefines;
  9622. private _currentRenderID;
  9623. private _boxBlurPostprocess;
  9624. private _kernelBlurXPostprocess;
  9625. private _kernelBlurYPostprocess;
  9626. private _blurPostProcesses;
  9627. private _mapSize;
  9628. private _currentFaceIndex;
  9629. private _currentFaceIndexCache;
  9630. private _textureType;
  9631. private _defaultTextureMatrix;
  9632. private _storedUniqueId;
  9633. /** @hidden */
  9634. static _SceneComponentInitialization: (scene: Scene) => void;
  9635. /**
  9636. * Creates a ShadowGenerator object.
  9637. * A ShadowGenerator is the required tool to use the shadows.
  9638. * Each light casting shadows needs to use its own ShadowGenerator.
  9639. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9640. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9641. * @param light The light object generating the shadows.
  9642. * @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.
  9643. */
  9644. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9645. private _initializeGenerator;
  9646. private _initializeShadowMap;
  9647. private _initializeBlurRTTAndPostProcesses;
  9648. private _renderForShadowMap;
  9649. private _renderSubMeshForShadowMap;
  9650. private _applyFilterValues;
  9651. /**
  9652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9653. * @param onCompiled Callback triggered at the and of the effects compilation
  9654. * @param options Sets of optional options forcing the compilation with different modes
  9655. */
  9656. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9657. useInstances: boolean;
  9658. }>): void;
  9659. /**
  9660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9661. * @param options Sets of optional options forcing the compilation with different modes
  9662. * @returns A promise that resolves when the compilation completes
  9663. */
  9664. forceCompilationAsync(options?: Partial<{
  9665. useInstances: boolean;
  9666. }>): Promise<void>;
  9667. /**
  9668. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9669. * @param subMesh The submesh we want to render in the shadow map
  9670. * @param useInstances Defines wether will draw in the map using instances
  9671. * @returns true if ready otherwise, false
  9672. */
  9673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9674. /**
  9675. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9676. * @param defines Defines of the material we want to update
  9677. * @param lightIndex Index of the light in the enabled light list of the material
  9678. */
  9679. prepareDefines(defines: any, lightIndex: number): void;
  9680. /**
  9681. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9682. * defined in the generator but impacting the effect).
  9683. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9684. * @param effect The effect we are binfing the information for
  9685. */
  9686. bindShadowLight(lightIndex: string, effect: Effect): void;
  9687. /**
  9688. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9689. * (eq to shadow prjection matrix * light transform matrix)
  9690. * @returns The transform matrix used to create the shadow map
  9691. */
  9692. getTransformMatrix(): Matrix;
  9693. /**
  9694. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9695. * Cube and 2D textures for instance.
  9696. */
  9697. recreateShadowMap(): void;
  9698. private _disposeBlurPostProcesses;
  9699. private _disposeRTTandPostProcesses;
  9700. /**
  9701. * Disposes the ShadowGenerator.
  9702. * Returns nothing.
  9703. */
  9704. dispose(): void;
  9705. /**
  9706. * Serializes the shadow generator setup to a json object.
  9707. * @returns The serialized JSON object
  9708. */
  9709. serialize(): any;
  9710. /**
  9711. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9712. * @param parsedShadowGenerator The JSON object to parse
  9713. * @param scene The scene to create the shadow map for
  9714. * @returns The parsed shadow generator
  9715. */
  9716. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9717. }
  9718. }
  9719. declare module BABYLON {
  9720. /**
  9721. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9722. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9723. * 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.
  9724. */
  9725. export abstract class Light extends Node {
  9726. /**
  9727. * Falloff Default: light is falling off following the material specification:
  9728. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9729. */
  9730. static readonly FALLOFF_DEFAULT: number;
  9731. /**
  9732. * Falloff Physical: light is falling off following the inverse squared distance law.
  9733. */
  9734. static readonly FALLOFF_PHYSICAL: number;
  9735. /**
  9736. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9737. * to enhance interoperability with other engines.
  9738. */
  9739. static readonly FALLOFF_GLTF: number;
  9740. /**
  9741. * Falloff Standard: light is falling off like in the standard material
  9742. * to enhance interoperability with other materials.
  9743. */
  9744. static readonly FALLOFF_STANDARD: number;
  9745. /**
  9746. * If every light affecting the material is in this lightmapMode,
  9747. * material.lightmapTexture adds or multiplies
  9748. * (depends on material.useLightmapAsShadowmap)
  9749. * after every other light calculations.
  9750. */
  9751. static readonly LIGHTMAP_DEFAULT: number;
  9752. /**
  9753. * material.lightmapTexture as only diffuse lighting from this light
  9754. * adds only specular lighting from this light
  9755. * adds dynamic shadows
  9756. */
  9757. static readonly LIGHTMAP_SPECULAR: number;
  9758. /**
  9759. * material.lightmapTexture as only lighting
  9760. * no light calculation from this light
  9761. * only adds dynamic shadows from this light
  9762. */
  9763. static readonly LIGHTMAP_SHADOWSONLY: number;
  9764. /**
  9765. * Each light type uses the default quantity according to its type:
  9766. * point/spot lights use luminous intensity
  9767. * directional lights use illuminance
  9768. */
  9769. static readonly INTENSITYMODE_AUTOMATIC: number;
  9770. /**
  9771. * lumen (lm)
  9772. */
  9773. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9774. /**
  9775. * candela (lm/sr)
  9776. */
  9777. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9778. /**
  9779. * lux (lm/m^2)
  9780. */
  9781. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9782. /**
  9783. * nit (cd/m^2)
  9784. */
  9785. static readonly INTENSITYMODE_LUMINANCE: number;
  9786. /**
  9787. * Light type const id of the point light.
  9788. */
  9789. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9790. /**
  9791. * Light type const id of the directional light.
  9792. */
  9793. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9794. /**
  9795. * Light type const id of the spot light.
  9796. */
  9797. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9798. /**
  9799. * Light type const id of the hemispheric light.
  9800. */
  9801. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9802. /**
  9803. * Diffuse gives the basic color to an object.
  9804. */
  9805. diffuse: Color3;
  9806. /**
  9807. * Specular produces a highlight color on an object.
  9808. * Note: This is note affecting PBR materials.
  9809. */
  9810. specular: Color3;
  9811. /**
  9812. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9813. * falling off base on range or angle.
  9814. * This can be set to any values in Light.FALLOFF_x.
  9815. *
  9816. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9817. * other types of materials.
  9818. */
  9819. falloffType: number;
  9820. /**
  9821. * Strength of the light.
  9822. * Note: By default it is define in the framework own unit.
  9823. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9824. */
  9825. intensity: number;
  9826. private _range;
  9827. protected _inverseSquaredRange: number;
  9828. /**
  9829. * Defines how far from the source the light is impacting in scene units.
  9830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9831. */
  9832. /**
  9833. * Defines how far from the source the light is impacting in scene units.
  9834. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9835. */
  9836. range: number;
  9837. /**
  9838. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9839. * of light.
  9840. */
  9841. private _photometricScale;
  9842. private _intensityMode;
  9843. /**
  9844. * Gets the photometric scale used to interpret the intensity.
  9845. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9846. */
  9847. /**
  9848. * Sets the photometric scale used to interpret the intensity.
  9849. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9850. */
  9851. intensityMode: number;
  9852. private _radius;
  9853. /**
  9854. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9855. */
  9856. /**
  9857. * sets the light radius used by PBR Materials to simulate soft area lights.
  9858. */
  9859. radius: number;
  9860. private _renderPriority;
  9861. /**
  9862. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9863. * exceeding the number allowed of the materials.
  9864. */
  9865. renderPriority: number;
  9866. private _shadowEnabled;
  9867. /**
  9868. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9869. * the current shadow generator.
  9870. */
  9871. /**
  9872. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9873. * the current shadow generator.
  9874. */
  9875. shadowEnabled: boolean;
  9876. private _includedOnlyMeshes;
  9877. /**
  9878. * Gets the only meshes impacted by this light.
  9879. */
  9880. /**
  9881. * Sets the only meshes impacted by this light.
  9882. */
  9883. includedOnlyMeshes: AbstractMesh[];
  9884. private _excludedMeshes;
  9885. /**
  9886. * Gets the meshes not impacted by this light.
  9887. */
  9888. /**
  9889. * Sets the meshes not impacted by this light.
  9890. */
  9891. excludedMeshes: AbstractMesh[];
  9892. private _excludeWithLayerMask;
  9893. /**
  9894. * Gets the layer id use to find what meshes are not impacted by the light.
  9895. * Inactive if 0
  9896. */
  9897. /**
  9898. * Sets the layer id use to find what meshes are not impacted by the light.
  9899. * Inactive if 0
  9900. */
  9901. excludeWithLayerMask: number;
  9902. private _includeOnlyWithLayerMask;
  9903. /**
  9904. * Gets the layer id use to find what meshes are impacted by the light.
  9905. * Inactive if 0
  9906. */
  9907. /**
  9908. * Sets the layer id use to find what meshes are impacted by the light.
  9909. * Inactive if 0
  9910. */
  9911. includeOnlyWithLayerMask: number;
  9912. private _lightmapMode;
  9913. /**
  9914. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9915. */
  9916. /**
  9917. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9918. */
  9919. lightmapMode: number;
  9920. /**
  9921. * Shadow generator associted to the light.
  9922. * @hidden Internal use only.
  9923. */
  9924. _shadowGenerator: Nullable<IShadowGenerator>;
  9925. /**
  9926. * @hidden Internal use only.
  9927. */
  9928. _excludedMeshesIds: string[];
  9929. /**
  9930. * @hidden Internal use only.
  9931. */
  9932. _includedOnlyMeshesIds: string[];
  9933. /**
  9934. * The current light unifom buffer.
  9935. * @hidden Internal use only.
  9936. */
  9937. _uniformBuffer: UniformBuffer;
  9938. /** @hidden */
  9939. _renderId: number;
  9940. /**
  9941. * Creates a Light object in the scene.
  9942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9943. * @param name The firendly name of the light
  9944. * @param scene The scene the light belongs too
  9945. */
  9946. constructor(name: string, scene: Scene);
  9947. protected abstract _buildUniformLayout(): void;
  9948. /**
  9949. * Sets the passed Effect "effect" with the Light information.
  9950. * @param effect The effect to update
  9951. * @param lightIndex The index of the light in the effect to update
  9952. * @returns The light
  9953. */
  9954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9955. /**
  9956. * Sets the passed Effect "effect" with the Light information.
  9957. * @param effect The effect to update
  9958. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9959. * @returns The light
  9960. */
  9961. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9962. /**
  9963. * Returns the string "Light".
  9964. * @returns the class name
  9965. */
  9966. getClassName(): string;
  9967. /** @hidden */
  9968. readonly _isLight: boolean;
  9969. /**
  9970. * Converts the light information to a readable string for debug purpose.
  9971. * @param fullDetails Supports for multiple levels of logging within scene loading
  9972. * @returns the human readable light info
  9973. */
  9974. toString(fullDetails?: boolean): string;
  9975. /** @hidden */
  9976. protected _syncParentEnabledState(): void;
  9977. /**
  9978. * Set the enabled state of this node.
  9979. * @param value - the new enabled state
  9980. */
  9981. setEnabled(value: boolean): void;
  9982. /**
  9983. * Returns the Light associated shadow generator if any.
  9984. * @return the associated shadow generator.
  9985. */
  9986. getShadowGenerator(): Nullable<IShadowGenerator>;
  9987. /**
  9988. * Returns a Vector3, the absolute light position in the World.
  9989. * @returns the world space position of the light
  9990. */
  9991. getAbsolutePosition(): Vector3;
  9992. /**
  9993. * Specifies if the light will affect the passed mesh.
  9994. * @param mesh The mesh to test against the light
  9995. * @return true the mesh is affected otherwise, false.
  9996. */
  9997. canAffectMesh(mesh: AbstractMesh): boolean;
  9998. /**
  9999. * Sort function to order lights for rendering.
  10000. * @param a First Light object to compare to second.
  10001. * @param b Second Light object to compare first.
  10002. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10003. */
  10004. static CompareLightsPriority(a: Light, b: Light): number;
  10005. /**
  10006. * Releases resources associated with this node.
  10007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10009. */
  10010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10011. /**
  10012. * Returns the light type ID (integer).
  10013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10014. */
  10015. getTypeID(): number;
  10016. /**
  10017. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10018. * @returns the scaled intensity in intensity mode unit
  10019. */
  10020. getScaledIntensity(): number;
  10021. /**
  10022. * Returns a new Light object, named "name", from the current one.
  10023. * @param name The name of the cloned light
  10024. * @returns the new created light
  10025. */
  10026. clone(name: string): Nullable<Light>;
  10027. /**
  10028. * Serializes the current light into a Serialization object.
  10029. * @returns the serialized object.
  10030. */
  10031. serialize(): any;
  10032. /**
  10033. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10034. * This new light is named "name" and added to the passed scene.
  10035. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10036. * @param name The friendly name of the light
  10037. * @param scene The scene the new light will belong to
  10038. * @returns the constructor function
  10039. */
  10040. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10041. /**
  10042. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10043. * @param parsedLight The JSON representation of the light
  10044. * @param scene The scene to create the parsed light in
  10045. * @returns the created light after parsing
  10046. */
  10047. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10048. private _hookArrayForExcluded;
  10049. private _hookArrayForIncludedOnly;
  10050. private _resyncMeshes;
  10051. /**
  10052. * Forces the meshes to update their light related information in their rendering used effects
  10053. * @hidden Internal Use Only
  10054. */
  10055. _markMeshesAsLightDirty(): void;
  10056. /**
  10057. * Recomputes the cached photometric scale if needed.
  10058. */
  10059. private _computePhotometricScale;
  10060. /**
  10061. * Returns the Photometric Scale according to the light type and intensity mode.
  10062. */
  10063. private _getPhotometricScale;
  10064. /**
  10065. * Reorder the light in the scene according to their defined priority.
  10066. * @hidden Internal Use Only
  10067. */
  10068. _reorderLightsInScene(): void;
  10069. /**
  10070. * Prepares the list of defines specific to the light type.
  10071. * @param defines the list of defines
  10072. * @param lightIndex defines the index of the light for the effect
  10073. */
  10074. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10075. }
  10076. }
  10077. declare module BABYLON {
  10078. /**
  10079. * Interface used to define Action
  10080. */
  10081. export interface IAction {
  10082. /**
  10083. * Trigger for the action
  10084. */
  10085. trigger: number;
  10086. /** Options of the trigger */
  10087. triggerOptions: any;
  10088. /**
  10089. * Gets the trigger parameters
  10090. * @returns the trigger parameters
  10091. */
  10092. getTriggerParameter(): any;
  10093. /**
  10094. * Internal only - executes current action event
  10095. * @hidden
  10096. */
  10097. _executeCurrent(evt?: ActionEvent): void;
  10098. /**
  10099. * Serialize placeholder for child classes
  10100. * @param parent of child
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. /**
  10105. * Internal only
  10106. * @hidden
  10107. */
  10108. _prepare(): void;
  10109. /**
  10110. * Internal only - manager for action
  10111. * @hidden
  10112. */
  10113. _actionManager: AbstractActionManager;
  10114. /**
  10115. * Adds action to chain of actions, may be a DoNothingAction
  10116. * @param action defines the next action to execute
  10117. * @returns The action passed in
  10118. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10119. */
  10120. then(action: IAction): IAction;
  10121. }
  10122. /**
  10123. * The action to be carried out following a trigger
  10124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10125. */
  10126. export class Action implements IAction {
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any;
  10129. /**
  10130. * Trigger for the action
  10131. */
  10132. trigger: number;
  10133. /**
  10134. * Internal only - manager for action
  10135. * @hidden
  10136. */
  10137. _actionManager: ActionManager;
  10138. private _nextActiveAction;
  10139. private _child;
  10140. private _condition?;
  10141. private _triggerParameter;
  10142. /**
  10143. * An event triggered prior to action being executed.
  10144. */
  10145. onBeforeExecuteObservable: Observable<Action>;
  10146. /**
  10147. * Creates a new Action
  10148. * @param triggerOptions the trigger, with or without parameters, for the action
  10149. * @param condition an optional determinant of action
  10150. */
  10151. constructor(
  10152. /** the trigger, with or without parameters, for the action */
  10153. triggerOptions: any, condition?: Condition);
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. _prepare(): void;
  10159. /**
  10160. * Gets the trigger parameters
  10161. * @returns the trigger parameters
  10162. */
  10163. getTriggerParameter(): any;
  10164. /**
  10165. * Internal only - executes current action event
  10166. * @hidden
  10167. */
  10168. _executeCurrent(evt?: ActionEvent): void;
  10169. /**
  10170. * Execute placeholder for child classes
  10171. * @param evt optional action event
  10172. */
  10173. execute(evt?: ActionEvent): void;
  10174. /**
  10175. * Skips to next active action
  10176. */
  10177. skipToNextActiveAction(): void;
  10178. /**
  10179. * Adds action to chain of actions, may be a DoNothingAction
  10180. * @param action defines the next action to execute
  10181. * @returns The action passed in
  10182. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10183. */
  10184. then(action: Action): Action;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. _getProperty(propertyPath: string): string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _getEffectiveTarget(target: any, propertyPath: string): any;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @param parent of child
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. /**
  10202. * Internal only called by serialize
  10203. * @hidden
  10204. */
  10205. protected _serialize(serializedAction: any, parent?: any): any;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. static _SerializeValueAsString: (value: any) => string;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. static _GetTargetProperty: (target: Node | Scene) => {
  10216. name: string;
  10217. targetType: string;
  10218. value: string;
  10219. };
  10220. }
  10221. }
  10222. declare module BABYLON {
  10223. /**
  10224. * A Condition applied to an Action
  10225. */
  10226. export class Condition {
  10227. /**
  10228. * Internal only - manager for action
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. _evaluationId: number;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. _currentResult: boolean;
  10242. /**
  10243. * Creates a new Condition
  10244. * @param actionManager the manager of the action the condition is applied to
  10245. */
  10246. constructor(actionManager: ActionManager);
  10247. /**
  10248. * Check if the current condition is valid
  10249. * @returns a boolean
  10250. */
  10251. isValid(): boolean;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. _getProperty(propertyPath: string): string;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _getEffectiveTarget(target: any, propertyPath: string): any;
  10262. /**
  10263. * Serialize placeholder for child classes
  10264. * @returns the serialized object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. protected _serialize(serializedCondition: any): any;
  10272. }
  10273. /**
  10274. * Defines specific conditional operators as extensions of Condition
  10275. */
  10276. export class ValueCondition extends Condition {
  10277. /** path to specify the property of the target the conditional operator uses */
  10278. propertyPath: string;
  10279. /** the value compared by the conditional operator against the current value of the property */
  10280. value: any;
  10281. /** the conditional operator, default ValueCondition.IsEqual */
  10282. operator: number;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private static _IsEqual;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. private static _IsDifferent;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. private static _IsGreater;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. private static _IsLesser;
  10303. /**
  10304. * returns the number for IsEqual
  10305. */
  10306. static readonly IsEqual: number;
  10307. /**
  10308. * Returns the number for IsDifferent
  10309. */
  10310. static readonly IsDifferent: number;
  10311. /**
  10312. * Returns the number for IsGreater
  10313. */
  10314. static readonly IsGreater: number;
  10315. /**
  10316. * Returns the number for IsLesser
  10317. */
  10318. static readonly IsLesser: number;
  10319. /**
  10320. * Internal only The action manager for the condition
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. private _target;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _effectiveTarget;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private _property;
  10339. /**
  10340. * Creates a new ValueCondition
  10341. * @param actionManager manager for the action the condition applies to
  10342. * @param target for the action
  10343. * @param propertyPath path to specify the property of the target the conditional operator uses
  10344. * @param value the value compared by the conditional operator against the current value of the property
  10345. * @param operator the conditional operator, default ValueCondition.IsEqual
  10346. */
  10347. constructor(actionManager: ActionManager, target: any,
  10348. /** path to specify the property of the target the conditional operator uses */
  10349. propertyPath: string,
  10350. /** the value compared by the conditional operator against the current value of the property */
  10351. value: any,
  10352. /** the conditional operator, default ValueCondition.IsEqual */
  10353. operator?: number);
  10354. /**
  10355. * Compares the given value with the property value for the specified conditional operator
  10356. * @returns the result of the comparison
  10357. */
  10358. isValid(): boolean;
  10359. /**
  10360. * Serialize the ValueCondition into a JSON compatible object
  10361. * @returns serialization object
  10362. */
  10363. serialize(): any;
  10364. /**
  10365. * Gets the name of the conditional operator for the ValueCondition
  10366. * @param operator the conditional operator
  10367. * @returns the name
  10368. */
  10369. static GetOperatorName(operator: number): string;
  10370. }
  10371. /**
  10372. * Defines a predicate condition as an extension of Condition
  10373. */
  10374. export class PredicateCondition extends Condition {
  10375. /** defines the predicate function used to validate the condition */
  10376. predicate: () => boolean;
  10377. /**
  10378. * Internal only - manager for action
  10379. * @hidden
  10380. */
  10381. _actionManager: ActionManager;
  10382. /**
  10383. * Creates a new PredicateCondition
  10384. * @param actionManager manager for the action the condition applies to
  10385. * @param predicate defines the predicate function used to validate the condition
  10386. */
  10387. constructor(actionManager: ActionManager,
  10388. /** defines the predicate function used to validate the condition */
  10389. predicate: () => boolean);
  10390. /**
  10391. * @returns the validity of the predicate condition
  10392. */
  10393. isValid(): boolean;
  10394. }
  10395. /**
  10396. * Defines a state condition as an extension of Condition
  10397. */
  10398. export class StateCondition extends Condition {
  10399. /** Value to compare with target state */
  10400. value: string;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: ActionManager;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private _target;
  10411. /**
  10412. * Creates a new StateCondition
  10413. * @param actionManager manager for the action the condition applies to
  10414. * @param target of the condition
  10415. * @param value to compare with target state
  10416. */
  10417. constructor(actionManager: ActionManager, target: any,
  10418. /** Value to compare with target state */
  10419. value: string);
  10420. /**
  10421. * Gets a boolean indicating if the current condition is met
  10422. * @returns the validity of the state
  10423. */
  10424. isValid(): boolean;
  10425. /**
  10426. * Serialize the StateCondition into a JSON compatible object
  10427. * @returns serialization object
  10428. */
  10429. serialize(): any;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * This defines an action responsible to toggle a boolean once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SwitchBooleanAction extends Action {
  10438. /**
  10439. * The path to the boolean property in the target object
  10440. */
  10441. propertyPath: string;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the boolean
  10449. * @param propertyPath defines the path to the boolean property in the target object
  10450. * @param condition defines the trigger related conditions
  10451. */
  10452. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10453. /** @hidden */
  10454. _prepare(): void;
  10455. /**
  10456. * Execute the action toggle the boolean value.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to set a the state field of the target
  10468. * to a desired value once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class SetStateAction extends Action {
  10472. /**
  10473. * The value to store in the state field.
  10474. */
  10475. value: string;
  10476. private _target;
  10477. /**
  10478. * Instantiate the action
  10479. * @param triggerOptions defines the trigger options
  10480. * @param target defines the object containing the state property
  10481. * @param value defines the value to store in the state field
  10482. * @param condition defines the trigger related conditions
  10483. */
  10484. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10485. /**
  10486. * Execute the action and store the value on the target state property.
  10487. */
  10488. execute(): void;
  10489. /**
  10490. * Serializes the actions and its related information.
  10491. * @param parent defines the object to serialize in
  10492. * @returns the serialized object
  10493. */
  10494. serialize(parent: any): any;
  10495. }
  10496. /**
  10497. * This defines an action responsible to set a property of the target
  10498. * to a desired value once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SetValueAction extends Action {
  10502. /**
  10503. * The path of the property to set in the target.
  10504. */
  10505. propertyPath: string;
  10506. /**
  10507. * The value to set in the property
  10508. */
  10509. value: any;
  10510. private _target;
  10511. private _effectiveTarget;
  10512. private _property;
  10513. /**
  10514. * Instantiate the action
  10515. * @param triggerOptions defines the trigger options
  10516. * @param target defines the object containing the property
  10517. * @param propertyPath defines the path of the property to set in the target
  10518. * @param value defines the value to set in the property
  10519. * @param condition defines the trigger related conditions
  10520. */
  10521. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10522. /** @hidden */
  10523. _prepare(): void;
  10524. /**
  10525. * Execute the action and set the targetted property to the desired value.
  10526. */
  10527. execute(): void;
  10528. /**
  10529. * Serializes the actions and its related information.
  10530. * @param parent defines the object to serialize in
  10531. * @returns the serialized object
  10532. */
  10533. serialize(parent: any): any;
  10534. }
  10535. /**
  10536. * This defines an action responsible to increment the target value
  10537. * to a desired value once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class IncrementValueAction extends Action {
  10541. /**
  10542. * The path of the property to increment in the target.
  10543. */
  10544. propertyPath: string;
  10545. /**
  10546. * The value we should increment the property by.
  10547. */
  10548. value: any;
  10549. private _target;
  10550. private _effectiveTarget;
  10551. private _property;
  10552. /**
  10553. * Instantiate the action
  10554. * @param triggerOptions defines the trigger options
  10555. * @param target defines the object containing the property
  10556. * @param propertyPath defines the path of the property to increment in the target
  10557. * @param value defines the value value we should increment the property by
  10558. * @param condition defines the trigger related conditions
  10559. */
  10560. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10561. /** @hidden */
  10562. _prepare(): void;
  10563. /**
  10564. * Execute the action and increment the target of the value amount.
  10565. */
  10566. execute(): void;
  10567. /**
  10568. * Serializes the actions and its related information.
  10569. * @param parent defines the object to serialize in
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. }
  10574. /**
  10575. * This defines an action responsible to start an animation once triggered.
  10576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10577. */
  10578. export class PlayAnimationAction extends Action {
  10579. /**
  10580. * Where the animation should start (animation frame)
  10581. */
  10582. from: number;
  10583. /**
  10584. * Where the animation should stop (animation frame)
  10585. */
  10586. to: number;
  10587. /**
  10588. * Define if the animation should loop or stop after the first play.
  10589. */
  10590. loop?: boolean;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the target animation or animation name
  10596. * @param from defines from where the animation should start (animation frame)
  10597. * @param end defines where the animation should stop (animation frame)
  10598. * @param loop defines if the animation should loop or stop after the first play
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and play the animation.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to stop an animation once triggered.
  10617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class StopAnimationAction extends Action {
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target animation or animation name
  10625. * @param condition defines the trigger related conditions
  10626. */
  10627. constructor(triggerOptions: any, target: any, condition?: Condition);
  10628. /** @hidden */
  10629. _prepare(): void;
  10630. /**
  10631. * Execute the action and stop the animation.
  10632. */
  10633. execute(): void;
  10634. /**
  10635. * Serializes the actions and its related information.
  10636. * @param parent defines the object to serialize in
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. }
  10641. /**
  10642. * This defines an action responsible that does nothing once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class DoNothingAction extends Action {
  10646. /**
  10647. * Instantiate the action
  10648. * @param triggerOptions defines the trigger options
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions?: any, condition?: Condition);
  10652. /**
  10653. * Execute the action and do nothing.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to trigger several actions once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class CombineAction extends Action {
  10668. /**
  10669. * The list of aggregated animations to run.
  10670. */
  10671. children: Action[];
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param children defines the list of aggregated animations to run
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action and executes all the aggregated actions.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to run code (external event) once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class ExecuteCodeAction extends Action {
  10697. /**
  10698. * The callback function to run.
  10699. */
  10700. func: (evt: ActionEvent) => void;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param func defines the callback function to run
  10705. * @param condition defines the trigger related conditions
  10706. */
  10707. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10708. /**
  10709. * Execute the action and run the attached code.
  10710. */
  10711. execute(evt: ActionEvent): void;
  10712. }
  10713. /**
  10714. * This defines an action responsible to set the parent property of the target once triggered.
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10716. */
  10717. export class SetParentAction extends Action {
  10718. private _parent;
  10719. private _target;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the target containing the parent property
  10724. * @param parent defines from where the animation should start (animation frame)
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and set the parent property.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. }
  10742. declare module BABYLON {
  10743. /**
  10744. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10745. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class ActionManager extends AbstractActionManager {
  10749. /**
  10750. * Nothing
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly NothingTrigger: number;
  10754. /**
  10755. * On pick
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnPickTrigger: number;
  10759. /**
  10760. * On left pick
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnLeftPickTrigger: number;
  10764. /**
  10765. * On right pick
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10767. */
  10768. static readonly OnRightPickTrigger: number;
  10769. /**
  10770. * On center pick
  10771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnCenterPickTrigger: number;
  10774. /**
  10775. * On pick down
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnPickDownTrigger: number;
  10779. /**
  10780. * On double pick
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnDoublePickTrigger: number;
  10784. /**
  10785. * On pick up
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPickUpTrigger: number;
  10789. /**
  10790. * On pick out.
  10791. * This trigger will only be raised if you also declared a OnPickDown
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10793. */
  10794. static readonly OnPickOutTrigger: number;
  10795. /**
  10796. * On long press
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly OnLongPressTrigger: number;
  10800. /**
  10801. * On pointer over
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPointerOverTrigger: number;
  10805. /**
  10806. * On pointer out
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPointerOutTrigger: number;
  10810. /**
  10811. * On every frame
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnEveryFrameTrigger: number;
  10815. /**
  10816. * On intersection enter
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnIntersectionEnterTrigger: number;
  10820. /**
  10821. * On intersection exit
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnIntersectionExitTrigger: number;
  10825. /**
  10826. * On key down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnKeyDownTrigger: number;
  10830. /**
  10831. * On key up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnKeyUpTrigger: number;
  10835. private _scene;
  10836. /**
  10837. * Creates a new action manager
  10838. * @param scene defines the hosting scene
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Releases all associated resources
  10843. */
  10844. dispose(): void;
  10845. /**
  10846. * Gets hosting scene
  10847. * @returns the hosting scene
  10848. */
  10849. getScene(): Scene;
  10850. /**
  10851. * Does this action manager handles actions of any of the given triggers
  10852. * @param triggers defines the triggers to be tested
  10853. * @return a boolean indicating whether one (or more) of the triggers is handled
  10854. */
  10855. hasSpecificTriggers(triggers: number[]): boolean;
  10856. /**
  10857. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10858. * speed.
  10859. * @param triggerA defines the trigger to be tested
  10860. * @param triggerB defines the trigger to be tested
  10861. * @return a boolean indicating whether one (or more) of the triggers is handled
  10862. */
  10863. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10864. /**
  10865. * Does this action manager handles actions of a given trigger
  10866. * @param trigger defines the trigger to be tested
  10867. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10868. * @return whether the trigger is handled
  10869. */
  10870. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10871. /**
  10872. * Does this action manager has pointer triggers
  10873. */
  10874. readonly hasPointerTriggers: boolean;
  10875. /**
  10876. * Does this action manager has pick triggers
  10877. */
  10878. readonly hasPickTriggers: boolean;
  10879. /**
  10880. * Registers an action to this action manager
  10881. * @param action defines the action to be registered
  10882. * @return the action amended (prepared) after registration
  10883. */
  10884. registerAction(action: IAction): Nullable<IAction>;
  10885. /**
  10886. * Unregisters an action to this action manager
  10887. * @param action defines the action to be unregistered
  10888. * @return a boolean indicating whether the action has been unregistered
  10889. */
  10890. unregisterAction(action: IAction): Boolean;
  10891. /**
  10892. * Process a specific trigger
  10893. * @param trigger defines the trigger to process
  10894. * @param evt defines the event details to be processed
  10895. */
  10896. processTrigger(trigger: number, evt?: IActionEvent): void;
  10897. /** @hidden */
  10898. _getEffectiveTarget(target: any, propertyPath: string): any;
  10899. /** @hidden */
  10900. _getProperty(propertyPath: string): string;
  10901. /**
  10902. * Serialize this manager to a JSON object
  10903. * @param name defines the property name to store this manager
  10904. * @returns a JSON representation of this manager
  10905. */
  10906. serialize(name: string): any;
  10907. /**
  10908. * Creates a new ActionManager from a JSON data
  10909. * @param parsedActions defines the JSON data to read from
  10910. * @param object defines the hosting mesh
  10911. * @param scene defines the hosting scene
  10912. */
  10913. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10914. /**
  10915. * Get a trigger name by index
  10916. * @param trigger defines the trigger index
  10917. * @returns a trigger name
  10918. */
  10919. static GetTriggerName(trigger: number): string;
  10920. }
  10921. }
  10922. declare module BABYLON {
  10923. /**
  10924. * Class representing a ray with position and direction
  10925. */
  10926. export class Ray {
  10927. /** origin point */
  10928. origin: Vector3;
  10929. /** direction */
  10930. direction: Vector3;
  10931. /** length of the ray */
  10932. length: number;
  10933. private static readonly TmpVector3;
  10934. private _tmpRay;
  10935. /**
  10936. * Creates a new ray
  10937. * @param origin origin point
  10938. * @param direction direction
  10939. * @param length length of the ray
  10940. */
  10941. constructor(
  10942. /** origin point */
  10943. origin: Vector3,
  10944. /** direction */
  10945. direction: Vector3,
  10946. /** length of the ray */
  10947. length?: number);
  10948. /**
  10949. * Checks if the ray intersects a box
  10950. * @param minimum bound of the box
  10951. * @param maximum bound of the box
  10952. * @param intersectionTreshold extra extend to be added to the box in all direction
  10953. * @returns if the box was hit
  10954. */
  10955. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10956. /**
  10957. * Checks if the ray intersects a box
  10958. * @param box the bounding box to check
  10959. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10960. * @returns if the box was hit
  10961. */
  10962. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10963. /**
  10964. * If the ray hits a sphere
  10965. * @param sphere the bounding sphere to check
  10966. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10967. * @returns true if it hits the sphere
  10968. */
  10969. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10970. /**
  10971. * If the ray hits a triange
  10972. * @param vertex0 triangle vertex
  10973. * @param vertex1 triangle vertex
  10974. * @param vertex2 triangle vertex
  10975. * @returns intersection information if hit
  10976. */
  10977. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10978. /**
  10979. * Checks if ray intersects a plane
  10980. * @param plane the plane to check
  10981. * @returns the distance away it was hit
  10982. */
  10983. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10984. /**
  10985. * Calculate the intercept of a ray on a given axis
  10986. * @param axis to check 'x' | 'y' | 'z'
  10987. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10988. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10989. */
  10990. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10991. /**
  10992. * Checks if ray intersects a mesh
  10993. * @param mesh the mesh to check
  10994. * @param fastCheck if only the bounding box should checked
  10995. * @returns picking info of the intersecton
  10996. */
  10997. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10998. /**
  10999. * Checks if ray intersects a mesh
  11000. * @param meshes the meshes to check
  11001. * @param fastCheck if only the bounding box should checked
  11002. * @param results array to store result in
  11003. * @returns Array of picking infos
  11004. */
  11005. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11006. private _comparePickingInfo;
  11007. private static smallnum;
  11008. private static rayl;
  11009. /**
  11010. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11011. * @param sega the first point of the segment to test the intersection against
  11012. * @param segb the second point of the segment to test the intersection against
  11013. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11014. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11015. */
  11016. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11017. /**
  11018. * Update the ray from viewport position
  11019. * @param x position
  11020. * @param y y position
  11021. * @param viewportWidth viewport width
  11022. * @param viewportHeight viewport height
  11023. * @param world world matrix
  11024. * @param view view matrix
  11025. * @param projection projection matrix
  11026. * @returns this ray updated
  11027. */
  11028. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11029. /**
  11030. * Creates a ray with origin and direction of 0,0,0
  11031. * @returns the new ray
  11032. */
  11033. static Zero(): Ray;
  11034. /**
  11035. * Creates a new ray from screen space and viewport
  11036. * @param x position
  11037. * @param y y position
  11038. * @param viewportWidth viewport width
  11039. * @param viewportHeight viewport height
  11040. * @param world world matrix
  11041. * @param view view matrix
  11042. * @param projection projection matrix
  11043. * @returns new ray
  11044. */
  11045. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11046. /**
  11047. * 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
  11048. * transformed to the given world matrix.
  11049. * @param origin The origin point
  11050. * @param end The end point
  11051. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11052. * @returns the new ray
  11053. */
  11054. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11055. /**
  11056. * Transforms a ray by a matrix
  11057. * @param ray ray to transform
  11058. * @param matrix matrix to apply
  11059. * @returns the resulting new ray
  11060. */
  11061. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11062. /**
  11063. * Transforms a ray by a matrix
  11064. * @param ray ray to transform
  11065. * @param matrix matrix to apply
  11066. * @param result ray to store result in
  11067. */
  11068. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11069. /**
  11070. * Unproject a ray from screen space to object space
  11071. * @param sourceX defines the screen space x coordinate to use
  11072. * @param sourceY defines the screen space y coordinate to use
  11073. * @param viewportWidth defines the current width of the viewport
  11074. * @param viewportHeight defines the current height of the viewport
  11075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11076. * @param view defines the view matrix to use
  11077. * @param projection defines the projection matrix to use
  11078. */
  11079. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11080. }
  11081. /**
  11082. * Type used to define predicate used to select faces when a mesh intersection is detected
  11083. */
  11084. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11085. interface Scene {
  11086. /** @hidden */
  11087. _tempPickingRay: Nullable<Ray>;
  11088. /** @hidden */
  11089. _cachedRayForTransform: Ray;
  11090. /** @hidden */
  11091. _pickWithRayInverseMatrix: Matrix;
  11092. /** @hidden */
  11093. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11094. /** @hidden */
  11095. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11096. }
  11097. }
  11098. declare module BABYLON {
  11099. /**
  11100. * Groups all the scene component constants in one place to ease maintenance.
  11101. * @hidden
  11102. */
  11103. export class SceneComponentConstants {
  11104. static readonly NAME_EFFECTLAYER: string;
  11105. static readonly NAME_LAYER: string;
  11106. static readonly NAME_LENSFLARESYSTEM: string;
  11107. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11108. static readonly NAME_PARTICLESYSTEM: string;
  11109. static readonly NAME_GAMEPAD: string;
  11110. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11111. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11112. static readonly NAME_DEPTHRENDERER: string;
  11113. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11114. static readonly NAME_SPRITE: string;
  11115. static readonly NAME_OUTLINERENDERER: string;
  11116. static readonly NAME_PROCEDURALTEXTURE: string;
  11117. static readonly NAME_SHADOWGENERATOR: string;
  11118. static readonly NAME_OCTREE: string;
  11119. static readonly NAME_PHYSICSENGINE: string;
  11120. static readonly NAME_AUDIO: string;
  11121. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11122. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11123. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11125. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11126. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11127. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11128. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11129. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11130. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11131. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11132. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11133. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11134. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11135. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11136. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11137. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11138. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11139. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11140. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11141. static readonly STEP_AFTERRENDER_AUDIO: number;
  11142. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11143. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11144. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11145. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11146. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11147. static readonly STEP_POINTERMOVE_SPRITE: number;
  11148. static readonly STEP_POINTERDOWN_SPRITE: number;
  11149. static readonly STEP_POINTERUP_SPRITE: number;
  11150. }
  11151. /**
  11152. * This represents a scene component.
  11153. *
  11154. * This is used to decouple the dependency the scene is having on the different workloads like
  11155. * layers, post processes...
  11156. */
  11157. export interface ISceneComponent {
  11158. /**
  11159. * The name of the component. Each component must have a unique name.
  11160. */
  11161. name: string;
  11162. /**
  11163. * The scene the component belongs to.
  11164. */
  11165. scene: Scene;
  11166. /**
  11167. * Register the component to one instance of a scene.
  11168. */
  11169. register(): void;
  11170. /**
  11171. * Rebuilds the elements related to this component in case of
  11172. * context lost for instance.
  11173. */
  11174. rebuild(): void;
  11175. /**
  11176. * Disposes the component and the associated ressources.
  11177. */
  11178. dispose(): void;
  11179. }
  11180. /**
  11181. * This represents a SERIALIZABLE scene component.
  11182. *
  11183. * This extends Scene Component to add Serialization methods on top.
  11184. */
  11185. export interface ISceneSerializableComponent extends ISceneComponent {
  11186. /**
  11187. * Adds all the elements from the container to the scene
  11188. * @param container the container holding the elements
  11189. */
  11190. addFromContainer(container: AbstractScene): void;
  11191. /**
  11192. * Removes all the elements in the container from the scene
  11193. * @param container contains the elements to remove
  11194. * @param dispose if the removed element should be disposed (default: false)
  11195. */
  11196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11197. /**
  11198. * Serializes the component data to the specified json object
  11199. * @param serializationObject The object to serialize to
  11200. */
  11201. serialize(serializationObject: any): void;
  11202. }
  11203. /**
  11204. * Strong typing of a Mesh related stage step action
  11205. */
  11206. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11207. /**
  11208. * Strong typing of a Evaluate Sub Mesh related stage step action
  11209. */
  11210. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11211. /**
  11212. * Strong typing of a Active Mesh related stage step action
  11213. */
  11214. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11215. /**
  11216. * Strong typing of a Camera related stage step action
  11217. */
  11218. export type CameraStageAction = (camera: Camera) => void;
  11219. /**
  11220. * Strong typing of a Camera Frame buffer related stage step action
  11221. */
  11222. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11223. /**
  11224. * Strong typing of a Render Target related stage step action
  11225. */
  11226. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11227. /**
  11228. * Strong typing of a RenderingGroup related stage step action
  11229. */
  11230. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11231. /**
  11232. * Strong typing of a Mesh Render related stage step action
  11233. */
  11234. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11235. /**
  11236. * Strong typing of a simple stage step action
  11237. */
  11238. export type SimpleStageAction = () => void;
  11239. /**
  11240. * Strong typing of a render target action.
  11241. */
  11242. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11243. /**
  11244. * Strong typing of a pointer move action.
  11245. */
  11246. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11247. /**
  11248. * Strong typing of a pointer up/down action.
  11249. */
  11250. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11251. /**
  11252. * Representation of a stage in the scene (Basically a list of ordered steps)
  11253. * @hidden
  11254. */
  11255. export class Stage<T extends Function> extends Array<{
  11256. index: number;
  11257. component: ISceneComponent;
  11258. action: T;
  11259. }> {
  11260. /**
  11261. * Hide ctor from the rest of the world.
  11262. * @param items The items to add.
  11263. */
  11264. private constructor();
  11265. /**
  11266. * Creates a new Stage.
  11267. * @returns A new instance of a Stage
  11268. */
  11269. static Create<T extends Function>(): Stage<T>;
  11270. /**
  11271. * Registers a step in an ordered way in the targeted stage.
  11272. * @param index Defines the position to register the step in
  11273. * @param component Defines the component attached to the step
  11274. * @param action Defines the action to launch during the step
  11275. */
  11276. registerStep(index: number, component: ISceneComponent, action: T): void;
  11277. /**
  11278. * Clears all the steps from the stage.
  11279. */
  11280. clear(): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface Scene {
  11285. /** @hidden */
  11286. _pointerOverSprite: Nullable<Sprite>;
  11287. /** @hidden */
  11288. _pickedDownSprite: Nullable<Sprite>;
  11289. /** @hidden */
  11290. _tempSpritePickingRay: Nullable<Ray>;
  11291. /**
  11292. * All of the sprite managers added to this scene
  11293. * @see http://doc.babylonjs.com/babylon101/sprites
  11294. */
  11295. spriteManagers: Array<ISpriteManager>;
  11296. /**
  11297. * An event triggered when sprites rendering is about to start
  11298. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11299. */
  11300. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11301. /**
  11302. * An event triggered when sprites rendering is done
  11303. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11304. */
  11305. onAfterSpritesRenderingObservable: Observable<Scene>;
  11306. /** @hidden */
  11307. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11308. /** Launch a ray to try to pick a sprite in the scene
  11309. * @param x position on screen
  11310. * @param y position on screen
  11311. * @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
  11312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11314. * @returns a PickingInfo
  11315. */
  11316. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11317. /** Use the given ray to pick a sprite in the scene
  11318. * @param ray The ray (in world space) to use to pick meshes
  11319. * @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
  11320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11322. * @returns a PickingInfo
  11323. */
  11324. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11325. /** @hidden */
  11326. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11327. /** Launch a ray to try to pick sprites in the scene
  11328. * @param x position on screen
  11329. * @param y position on screen
  11330. * @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
  11331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /** Use the given ray to pick sprites in the scene
  11336. * @param ray The ray (in world space) to use to pick meshes
  11337. * @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
  11338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11339. * @returns a PickingInfo array
  11340. */
  11341. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11342. /**
  11343. * Force the sprite under the pointer
  11344. * @param sprite defines the sprite to use
  11345. */
  11346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11347. /**
  11348. * Gets the sprite under the pointer
  11349. * @returns a Sprite or null if no sprite is under the pointer
  11350. */
  11351. getPointerOverSprite(): Nullable<Sprite>;
  11352. }
  11353. /**
  11354. * Defines the sprite scene component responsible to manage sprites
  11355. * in a given scene.
  11356. */
  11357. export class SpriteSceneComponent implements ISceneComponent {
  11358. /**
  11359. * The component name helpfull to identify the component in the list of scene components.
  11360. */
  11361. readonly name: string;
  11362. /**
  11363. * The scene the component belongs to.
  11364. */
  11365. scene: Scene;
  11366. /** @hidden */
  11367. private _spritePredicate;
  11368. /**
  11369. * Creates a new instance of the component for the given scene
  11370. * @param scene Defines the scene to register the component in
  11371. */
  11372. constructor(scene: Scene);
  11373. /**
  11374. * Registers the component in a given scene
  11375. */
  11376. register(): void;
  11377. /**
  11378. * Rebuilds the elements related to this component in case of
  11379. * context lost for instance.
  11380. */
  11381. rebuild(): void;
  11382. /**
  11383. * Disposes the component and the associated ressources.
  11384. */
  11385. dispose(): void;
  11386. private _pickSpriteButKeepRay;
  11387. private _pointerMove;
  11388. private _pointerDown;
  11389. private _pointerUp;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /** @hidden */
  11394. export var fogFragmentDeclaration: {
  11395. name: string;
  11396. shader: string;
  11397. };
  11398. }
  11399. declare module BABYLON {
  11400. /** @hidden */
  11401. export var fogFragment: {
  11402. name: string;
  11403. shader: string;
  11404. };
  11405. }
  11406. declare module BABYLON {
  11407. /** @hidden */
  11408. export var spritesPixelShader: {
  11409. name: string;
  11410. shader: string;
  11411. };
  11412. }
  11413. declare module BABYLON {
  11414. /** @hidden */
  11415. export var fogVertexDeclaration: {
  11416. name: string;
  11417. shader: string;
  11418. };
  11419. }
  11420. declare module BABYLON {
  11421. /** @hidden */
  11422. export var spritesVertexShader: {
  11423. name: string;
  11424. shader: string;
  11425. };
  11426. }
  11427. declare module BABYLON {
  11428. /**
  11429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11430. */
  11431. export interface ISpriteManager extends IDisposable {
  11432. /**
  11433. * Restricts the camera to viewing objects with the same layerMask.
  11434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11435. */
  11436. layerMask: number;
  11437. /**
  11438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11439. */
  11440. isPickable: boolean;
  11441. /**
  11442. * Specifies the rendering group id for this mesh (0 by default)
  11443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11444. */
  11445. renderingGroupId: number;
  11446. /**
  11447. * Defines the list of sprites managed by the manager.
  11448. */
  11449. sprites: Array<Sprite>;
  11450. /**
  11451. * Tests the intersection of a sprite with a specific ray.
  11452. * @param ray The ray we are sending to test the collision
  11453. * @param camera The camera space we are sending rays in
  11454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11456. * @returns picking info or null.
  11457. */
  11458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11459. /**
  11460. * Intersects the sprites with a ray
  11461. * @param ray defines the ray to intersect with
  11462. * @param camera defines the current active camera
  11463. * @param predicate defines a predicate used to select candidate sprites
  11464. * @returns null if no hit or a PickingInfo array
  11465. */
  11466. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11467. /**
  11468. * Renders the list of sprites on screen.
  11469. */
  11470. render(): void;
  11471. }
  11472. /**
  11473. * Class used to manage multiple sprites on the same spritesheet
  11474. * @see http://doc.babylonjs.com/babylon101/sprites
  11475. */
  11476. export class SpriteManager implements ISpriteManager {
  11477. /** defines the manager's name */
  11478. name: string;
  11479. /** Gets the list of sprites */
  11480. sprites: Sprite[];
  11481. /** Gets or sets the rendering group id (0 by default) */
  11482. renderingGroupId: number;
  11483. /** Gets or sets camera layer mask */
  11484. layerMask: number;
  11485. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11486. fogEnabled: boolean;
  11487. /** Gets or sets a boolean indicating if the sprites are pickable */
  11488. isPickable: boolean;
  11489. /** Defines the default width of a cell in the spritesheet */
  11490. cellWidth: number;
  11491. /** Defines the default height of a cell in the spritesheet */
  11492. cellHeight: number;
  11493. /** Associative array from JSON sprite data file */
  11494. private _cellData;
  11495. /** Array of sprite names from JSON sprite data file */
  11496. private _spriteMap;
  11497. /** True when packed cell data from JSON file is ready*/
  11498. private _packedAndReady;
  11499. /**
  11500. * An event triggered when the manager is disposed.
  11501. */
  11502. onDisposeObservable: Observable<SpriteManager>;
  11503. private _onDisposeObserver;
  11504. /**
  11505. * Callback called when the manager is disposed
  11506. */
  11507. onDispose: () => void;
  11508. private _capacity;
  11509. private _fromPacked;
  11510. private _spriteTexture;
  11511. private _epsilon;
  11512. private _scene;
  11513. private _vertexData;
  11514. private _buffer;
  11515. private _vertexBuffers;
  11516. private _indexBuffer;
  11517. private _effectBase;
  11518. private _effectFog;
  11519. /**
  11520. * Gets or sets the spritesheet texture
  11521. */
  11522. texture: Texture;
  11523. /**
  11524. * Creates a new sprite manager
  11525. * @param name defines the manager's name
  11526. * @param imgUrl defines the sprite sheet url
  11527. * @param capacity defines the maximum allowed number of sprites
  11528. * @param cellSize defines the size of a sprite cell
  11529. * @param scene defines the hosting scene
  11530. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11531. * @param samplingMode defines the smapling mode to use with spritesheet
  11532. * @param fromPacked set to false; do not alter
  11533. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11534. */
  11535. constructor(
  11536. /** defines the manager's name */
  11537. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11538. private _makePacked;
  11539. private _appendSpriteVertex;
  11540. /**
  11541. * Intersects the sprites with a ray
  11542. * @param ray defines the ray to intersect with
  11543. * @param camera defines the current active camera
  11544. * @param predicate defines a predicate used to select candidate sprites
  11545. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11546. * @returns null if no hit or a PickingInfo
  11547. */
  11548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11549. /**
  11550. * Intersects the sprites with a ray
  11551. * @param ray defines the ray to intersect with
  11552. * @param camera defines the current active camera
  11553. * @param predicate defines a predicate used to select candidate sprites
  11554. * @returns null if no hit or a PickingInfo array
  11555. */
  11556. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Render all child sprites
  11559. */
  11560. render(): void;
  11561. /**
  11562. * Release associated resources
  11563. */
  11564. dispose(): void;
  11565. }
  11566. }
  11567. declare module BABYLON {
  11568. /**
  11569. * Class used to represent a sprite
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. export class Sprite {
  11573. /** defines the name */
  11574. name: string;
  11575. /** Gets or sets the current world position */
  11576. position: Vector3;
  11577. /** Gets or sets the main color */
  11578. color: Color4;
  11579. /** Gets or sets the width */
  11580. width: number;
  11581. /** Gets or sets the height */
  11582. height: number;
  11583. /** Gets or sets rotation angle */
  11584. angle: number;
  11585. /** Gets or sets the cell index in the sprite sheet */
  11586. cellIndex: number;
  11587. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11588. cellRef: string;
  11589. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11590. invertU: number;
  11591. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11592. invertV: number;
  11593. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11594. disposeWhenFinishedAnimating: boolean;
  11595. /** Gets the list of attached animations */
  11596. animations: Animation[];
  11597. /** Gets or sets a boolean indicating if the sprite can be picked */
  11598. isPickable: boolean;
  11599. /**
  11600. * Gets or sets the associated action manager
  11601. */
  11602. actionManager: Nullable<ActionManager>;
  11603. private _animationStarted;
  11604. private _loopAnimation;
  11605. private _fromIndex;
  11606. private _toIndex;
  11607. private _delay;
  11608. private _direction;
  11609. private _manager;
  11610. private _time;
  11611. private _onAnimationEnd;
  11612. /**
  11613. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11614. */
  11615. isVisible: boolean;
  11616. /**
  11617. * Gets or sets the sprite size
  11618. */
  11619. size: number;
  11620. /**
  11621. * Creates a new Sprite
  11622. * @param name defines the name
  11623. * @param manager defines the manager
  11624. */
  11625. constructor(
  11626. /** defines the name */
  11627. name: string, manager: ISpriteManager);
  11628. /**
  11629. * Starts an animation
  11630. * @param from defines the initial key
  11631. * @param to defines the end key
  11632. * @param loop defines if the animation must loop
  11633. * @param delay defines the start delay (in ms)
  11634. * @param onAnimationEnd defines a callback to call when animation ends
  11635. */
  11636. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11637. /** Stops current animation (if any) */
  11638. stopAnimation(): void;
  11639. /** @hidden */
  11640. _animate(deltaTime: number): void;
  11641. /** Release associated resources */
  11642. dispose(): void;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /**
  11647. * Information about the result of picking within a scene
  11648. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11649. */
  11650. export class PickingInfo {
  11651. /** @hidden */
  11652. _pickingUnavailable: boolean;
  11653. /**
  11654. * If the pick collided with an object
  11655. */
  11656. hit: boolean;
  11657. /**
  11658. * Distance away where the pick collided
  11659. */
  11660. distance: number;
  11661. /**
  11662. * The location of pick collision
  11663. */
  11664. pickedPoint: Nullable<Vector3>;
  11665. /**
  11666. * The mesh corresponding the the pick collision
  11667. */
  11668. pickedMesh: Nullable<AbstractMesh>;
  11669. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11670. bu: number;
  11671. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11672. bv: number;
  11673. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11674. faceId: number;
  11675. /** Id of the the submesh that was picked */
  11676. subMeshId: number;
  11677. /** If a sprite was picked, this will be the sprite the pick collided with */
  11678. pickedSprite: Nullable<Sprite>;
  11679. /**
  11680. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11681. */
  11682. originMesh: Nullable<AbstractMesh>;
  11683. /**
  11684. * The ray that was used to perform the picking.
  11685. */
  11686. ray: Nullable<Ray>;
  11687. /**
  11688. * Gets the normal correspodning to the face the pick collided with
  11689. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11690. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11691. * @returns The normal correspodning to the face the pick collided with
  11692. */
  11693. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11694. /**
  11695. * Gets the texture coordinates of where the pick occured
  11696. * @returns the vector containing the coordnates of the texture
  11697. */
  11698. getTextureCoordinates(): Nullable<Vector2>;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. /**
  11703. * Gather the list of pointer event types as constants.
  11704. */
  11705. export class PointerEventTypes {
  11706. /**
  11707. * 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.
  11708. */
  11709. static readonly POINTERDOWN: number;
  11710. /**
  11711. * The pointerup event is fired when a pointer is no longer active.
  11712. */
  11713. static readonly POINTERUP: number;
  11714. /**
  11715. * The pointermove event is fired when a pointer changes coordinates.
  11716. */
  11717. static readonly POINTERMOVE: number;
  11718. /**
  11719. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11720. */
  11721. static readonly POINTERWHEEL: number;
  11722. /**
  11723. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11724. */
  11725. static readonly POINTERPICK: number;
  11726. /**
  11727. * The pointertap event is fired when a the object has been touched and released without drag.
  11728. */
  11729. static readonly POINTERTAP: number;
  11730. /**
  11731. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11732. */
  11733. static readonly POINTERDOUBLETAP: number;
  11734. }
  11735. /**
  11736. * Base class of pointer info types.
  11737. */
  11738. export class PointerInfoBase {
  11739. /**
  11740. * Defines the type of event (PointerEventTypes)
  11741. */
  11742. type: number;
  11743. /**
  11744. * Defines the related dom event
  11745. */
  11746. event: PointerEvent | MouseWheelEvent;
  11747. /**
  11748. * Instantiates the base class of pointers info.
  11749. * @param type Defines the type of event (PointerEventTypes)
  11750. * @param event Defines the related dom event
  11751. */
  11752. constructor(
  11753. /**
  11754. * Defines the type of event (PointerEventTypes)
  11755. */
  11756. type: number,
  11757. /**
  11758. * Defines the related dom event
  11759. */
  11760. event: PointerEvent | MouseWheelEvent);
  11761. }
  11762. /**
  11763. * This class is used to store pointer related info for the onPrePointerObservable event.
  11764. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11765. */
  11766. export class PointerInfoPre extends PointerInfoBase {
  11767. /**
  11768. * Ray from a pointer if availible (eg. 6dof controller)
  11769. */
  11770. ray: Nullable<Ray>;
  11771. /**
  11772. * Defines the local position of the pointer on the canvas.
  11773. */
  11774. localPosition: Vector2;
  11775. /**
  11776. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11777. */
  11778. skipOnPointerObservable: boolean;
  11779. /**
  11780. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11781. * @param type Defines the type of event (PointerEventTypes)
  11782. * @param event Defines the related dom event
  11783. * @param localX Defines the local x coordinates of the pointer when the event occured
  11784. * @param localY Defines the local y coordinates of the pointer when the event occured
  11785. */
  11786. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11787. }
  11788. /**
  11789. * This type contains all the data related to a pointer event in Babylon.js.
  11790. * 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.
  11791. */
  11792. export class PointerInfo extends PointerInfoBase {
  11793. /**
  11794. * Defines the picking info associated to the info (if any)\
  11795. */
  11796. pickInfo: Nullable<PickingInfo>;
  11797. /**
  11798. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11799. * @param type Defines the type of event (PointerEventTypes)
  11800. * @param event Defines the related dom event
  11801. * @param pickInfo Defines the picking info associated to the info (if any)\
  11802. */
  11803. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11804. /**
  11805. * Defines the picking info associated to the info (if any)\
  11806. */
  11807. pickInfo: Nullable<PickingInfo>);
  11808. }
  11809. /**
  11810. * Data relating to a touch event on the screen.
  11811. */
  11812. export interface PointerTouch {
  11813. /**
  11814. * X coordinate of touch.
  11815. */
  11816. x: number;
  11817. /**
  11818. * Y coordinate of touch.
  11819. */
  11820. y: number;
  11821. /**
  11822. * Id of touch. Unique for each finger.
  11823. */
  11824. pointerId: number;
  11825. /**
  11826. * Event type passed from DOM.
  11827. */
  11828. type: any;
  11829. }
  11830. }
  11831. declare module BABYLON {
  11832. /**
  11833. * Manage the mouse inputs to control the movement of a free camera.
  11834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11835. */
  11836. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11837. /**
  11838. * Define if touch is enabled in the mouse input
  11839. */
  11840. touchEnabled: boolean;
  11841. /**
  11842. * Defines the camera the input is attached to.
  11843. */
  11844. camera: FreeCamera;
  11845. /**
  11846. * Defines the buttons associated with the input to handle camera move.
  11847. */
  11848. buttons: number[];
  11849. /**
  11850. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11851. */
  11852. angularSensibility: number;
  11853. private _pointerInput;
  11854. private _onMouseMove;
  11855. private _observer;
  11856. private previousPosition;
  11857. /**
  11858. * Observable for when a pointer move event occurs containing the move offset
  11859. */
  11860. onPointerMovedObservable: Observable<{
  11861. offsetX: number;
  11862. offsetY: number;
  11863. }>;
  11864. /**
  11865. * @hidden
  11866. * If the camera should be rotated automatically based on pointer movement
  11867. */
  11868. _allowCameraRotation: boolean;
  11869. /**
  11870. * Manage the mouse inputs to control the movement of a free camera.
  11871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11872. * @param touchEnabled Defines if touch is enabled or not
  11873. */
  11874. constructor(
  11875. /**
  11876. * Define if touch is enabled in the mouse input
  11877. */
  11878. touchEnabled?: boolean);
  11879. /**
  11880. * Attach the input controls to a specific dom element to get the input from.
  11881. * @param element Defines the element the controls should be listened from
  11882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11883. */
  11884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11885. /**
  11886. * Called on JS contextmenu event.
  11887. * Override this method to provide functionality.
  11888. */
  11889. protected onContextMenu(evt: PointerEvent): void;
  11890. /**
  11891. * Detach the current controls from the specified dom element.
  11892. * @param element Defines the element to stop listening the inputs from
  11893. */
  11894. detachControl(element: Nullable<HTMLElement>): void;
  11895. /**
  11896. * Gets the class name of the current intput.
  11897. * @returns the class name
  11898. */
  11899. getClassName(): string;
  11900. /**
  11901. * Get the friendly name associated with the input class.
  11902. * @returns the input friendly name
  11903. */
  11904. getSimpleName(): string;
  11905. }
  11906. }
  11907. declare module BABYLON {
  11908. /**
  11909. * Manage the touch inputs to control the movement of a free camera.
  11910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11911. */
  11912. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11913. /**
  11914. * Defines the camera the input is attached to.
  11915. */
  11916. camera: FreeCamera;
  11917. /**
  11918. * Defines the touch sensibility for rotation.
  11919. * The higher the faster.
  11920. */
  11921. touchAngularSensibility: number;
  11922. /**
  11923. * Defines the touch sensibility for move.
  11924. * The higher the faster.
  11925. */
  11926. touchMoveSensibility: number;
  11927. private _offsetX;
  11928. private _offsetY;
  11929. private _pointerPressed;
  11930. private _pointerInput;
  11931. private _observer;
  11932. private _onLostFocus;
  11933. /**
  11934. * Attach the input controls to a specific dom element to get the input from.
  11935. * @param element Defines the element the controls should be listened from
  11936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11937. */
  11938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11939. /**
  11940. * Detach the current controls from the specified dom element.
  11941. * @param element Defines the element to stop listening the inputs from
  11942. */
  11943. detachControl(element: Nullable<HTMLElement>): void;
  11944. /**
  11945. * Update the current camera state depending on the inputs that have been used this frame.
  11946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11947. */
  11948. checkInputs(): void;
  11949. /**
  11950. * Gets the class name of the current intput.
  11951. * @returns the class name
  11952. */
  11953. getClassName(): string;
  11954. /**
  11955. * Get the friendly name associated with the input class.
  11956. * @returns the input friendly name
  11957. */
  11958. getSimpleName(): string;
  11959. }
  11960. }
  11961. declare module BABYLON {
  11962. /**
  11963. * Default Inputs manager for the FreeCamera.
  11964. * It groups all the default supported inputs for ease of use.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11968. /**
  11969. * @hidden
  11970. */
  11971. _mouseInput: Nullable<FreeCameraMouseInput>;
  11972. /**
  11973. * Instantiates a new FreeCameraInputsManager.
  11974. * @param camera Defines the camera the inputs belong to
  11975. */
  11976. constructor(camera: FreeCamera);
  11977. /**
  11978. * Add keyboard input support to the input manager.
  11979. * @returns the current input manager
  11980. */
  11981. addKeyboard(): FreeCameraInputsManager;
  11982. /**
  11983. * Add mouse input support to the input manager.
  11984. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11985. * @returns the current input manager
  11986. */
  11987. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11988. /**
  11989. * Removes the mouse input support from the manager
  11990. * @returns the current input manager
  11991. */
  11992. removeMouse(): FreeCameraInputsManager;
  11993. /**
  11994. * Add touch input support to the input manager.
  11995. * @returns the current input manager
  11996. */
  11997. addTouch(): FreeCameraInputsManager;
  11998. /**
  11999. * Remove all attached input methods from a camera
  12000. */
  12001. clear(): void;
  12002. }
  12003. }
  12004. declare module BABYLON {
  12005. /**
  12006. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12007. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12009. */
  12010. export class FreeCamera extends TargetCamera {
  12011. /**
  12012. * Define the collision ellipsoid of the camera.
  12013. * This is helpful to simulate a camera body like the player body around the camera
  12014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12015. */
  12016. ellipsoid: Vector3;
  12017. /**
  12018. * Define an offset for the position of the ellipsoid around the camera.
  12019. * This can be helpful to determine the center of the body near the gravity center of the body
  12020. * instead of its head.
  12021. */
  12022. ellipsoidOffset: Vector3;
  12023. /**
  12024. * Enable or disable collisions of the camera with the rest of the scene objects.
  12025. */
  12026. checkCollisions: boolean;
  12027. /**
  12028. * Enable or disable gravity on the camera.
  12029. */
  12030. applyGravity: boolean;
  12031. /**
  12032. * Define the input manager associated to the camera.
  12033. */
  12034. inputs: FreeCameraInputsManager;
  12035. /**
  12036. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12037. * Higher values reduce sensitivity.
  12038. */
  12039. /**
  12040. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12041. * Higher values reduce sensitivity.
  12042. */
  12043. angularSensibility: number;
  12044. /**
  12045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12046. */
  12047. keysUp: number[];
  12048. /**
  12049. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12050. */
  12051. keysDown: number[];
  12052. /**
  12053. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12054. */
  12055. keysLeft: number[];
  12056. /**
  12057. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12058. */
  12059. keysRight: number[];
  12060. /**
  12061. * Event raised when the camera collide with a mesh in the scene.
  12062. */
  12063. onCollide: (collidedMesh: AbstractMesh) => void;
  12064. private _collider;
  12065. private _needMoveForGravity;
  12066. private _oldPosition;
  12067. private _diffPosition;
  12068. private _newPosition;
  12069. /** @hidden */
  12070. _localDirection: Vector3;
  12071. /** @hidden */
  12072. _transformedDirection: Vector3;
  12073. /**
  12074. * Instantiates a Free Camera.
  12075. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12076. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12078. * @param name Define the name of the camera in the scene
  12079. * @param position Define the start position of the camera in the scene
  12080. * @param scene Define the scene the camera belongs to
  12081. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12082. */
  12083. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12084. /**
  12085. * Attached controls to the current camera.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Detach the current controls from the camera.
  12092. * The camera will stop reacting to inputs.
  12093. * @param element Defines the element to stop listening the inputs from
  12094. */
  12095. detachControl(element: HTMLElement): void;
  12096. private _collisionMask;
  12097. /**
  12098. * Define a collision mask to limit the list of object the camera can collide with
  12099. */
  12100. collisionMask: number;
  12101. /** @hidden */
  12102. _collideWithWorld(displacement: Vector3): void;
  12103. private _onCollisionPositionChange;
  12104. /** @hidden */
  12105. _checkInputs(): void;
  12106. /** @hidden */
  12107. _decideIfNeedsToMove(): boolean;
  12108. /** @hidden */
  12109. _updatePosition(): void;
  12110. /**
  12111. * Destroy the camera and release the current resources hold by it.
  12112. */
  12113. dispose(): void;
  12114. /**
  12115. * Gets the current object class name.
  12116. * @return the class name
  12117. */
  12118. getClassName(): string;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Represents a gamepad control stick position
  12124. */
  12125. export class StickValues {
  12126. /**
  12127. * The x component of the control stick
  12128. */
  12129. x: number;
  12130. /**
  12131. * The y component of the control stick
  12132. */
  12133. y: number;
  12134. /**
  12135. * Initializes the gamepad x and y control stick values
  12136. * @param x The x component of the gamepad control stick value
  12137. * @param y The y component of the gamepad control stick value
  12138. */
  12139. constructor(
  12140. /**
  12141. * The x component of the control stick
  12142. */
  12143. x: number,
  12144. /**
  12145. * The y component of the control stick
  12146. */
  12147. y: number);
  12148. }
  12149. /**
  12150. * An interface which manages callbacks for gamepad button changes
  12151. */
  12152. export interface GamepadButtonChanges {
  12153. /**
  12154. * Called when a gamepad has been changed
  12155. */
  12156. changed: boolean;
  12157. /**
  12158. * Called when a gamepad press event has been triggered
  12159. */
  12160. pressChanged: boolean;
  12161. /**
  12162. * Called when a touch event has been triggered
  12163. */
  12164. touchChanged: boolean;
  12165. /**
  12166. * Called when a value has changed
  12167. */
  12168. valueChanged: boolean;
  12169. }
  12170. /**
  12171. * Represents a gamepad
  12172. */
  12173. export class Gamepad {
  12174. /**
  12175. * The id of the gamepad
  12176. */
  12177. id: string;
  12178. /**
  12179. * The index of the gamepad
  12180. */
  12181. index: number;
  12182. /**
  12183. * The browser gamepad
  12184. */
  12185. browserGamepad: any;
  12186. /**
  12187. * Specifies what type of gamepad this represents
  12188. */
  12189. type: number;
  12190. private _leftStick;
  12191. private _rightStick;
  12192. /** @hidden */
  12193. _isConnected: boolean;
  12194. private _leftStickAxisX;
  12195. private _leftStickAxisY;
  12196. private _rightStickAxisX;
  12197. private _rightStickAxisY;
  12198. /**
  12199. * Triggered when the left control stick has been changed
  12200. */
  12201. private _onleftstickchanged;
  12202. /**
  12203. * Triggered when the right control stick has been changed
  12204. */
  12205. private _onrightstickchanged;
  12206. /**
  12207. * Represents a gamepad controller
  12208. */
  12209. static GAMEPAD: number;
  12210. /**
  12211. * Represents a generic controller
  12212. */
  12213. static GENERIC: number;
  12214. /**
  12215. * Represents an XBox controller
  12216. */
  12217. static XBOX: number;
  12218. /**
  12219. * Represents a pose-enabled controller
  12220. */
  12221. static POSE_ENABLED: number;
  12222. /**
  12223. * Represents an Dual Shock controller
  12224. */
  12225. static DUALSHOCK: number;
  12226. /**
  12227. * Specifies whether the left control stick should be Y-inverted
  12228. */
  12229. protected _invertLeftStickY: boolean;
  12230. /**
  12231. * Specifies if the gamepad has been connected
  12232. */
  12233. readonly isConnected: boolean;
  12234. /**
  12235. * Initializes the gamepad
  12236. * @param id The id of the gamepad
  12237. * @param index The index of the gamepad
  12238. * @param browserGamepad The browser gamepad
  12239. * @param leftStickX The x component of the left joystick
  12240. * @param leftStickY The y component of the left joystick
  12241. * @param rightStickX The x component of the right joystick
  12242. * @param rightStickY The y component of the right joystick
  12243. */
  12244. constructor(
  12245. /**
  12246. * The id of the gamepad
  12247. */
  12248. id: string,
  12249. /**
  12250. * The index of the gamepad
  12251. */
  12252. index: number,
  12253. /**
  12254. * The browser gamepad
  12255. */
  12256. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12257. /**
  12258. * Callback triggered when the left joystick has changed
  12259. * @param callback
  12260. */
  12261. onleftstickchanged(callback: (values: StickValues) => void): void;
  12262. /**
  12263. * Callback triggered when the right joystick has changed
  12264. * @param callback
  12265. */
  12266. onrightstickchanged(callback: (values: StickValues) => void): void;
  12267. /**
  12268. * Gets the left joystick
  12269. */
  12270. /**
  12271. * Sets the left joystick values
  12272. */
  12273. leftStick: StickValues;
  12274. /**
  12275. * Gets the right joystick
  12276. */
  12277. /**
  12278. * Sets the right joystick value
  12279. */
  12280. rightStick: StickValues;
  12281. /**
  12282. * Updates the gamepad joystick positions
  12283. */
  12284. update(): void;
  12285. /**
  12286. * Disposes the gamepad
  12287. */
  12288. dispose(): void;
  12289. }
  12290. /**
  12291. * Represents a generic gamepad
  12292. */
  12293. export class GenericPad extends Gamepad {
  12294. private _buttons;
  12295. private _onbuttondown;
  12296. private _onbuttonup;
  12297. /**
  12298. * Observable triggered when a button has been pressed
  12299. */
  12300. onButtonDownObservable: Observable<number>;
  12301. /**
  12302. * Observable triggered when a button has been released
  12303. */
  12304. onButtonUpObservable: Observable<number>;
  12305. /**
  12306. * Callback triggered when a button has been pressed
  12307. * @param callback Called when a button has been pressed
  12308. */
  12309. onbuttondown(callback: (buttonPressed: number) => void): void;
  12310. /**
  12311. * Callback triggered when a button has been released
  12312. * @param callback Called when a button has been released
  12313. */
  12314. onbuttonup(callback: (buttonReleased: number) => void): void;
  12315. /**
  12316. * Initializes the generic gamepad
  12317. * @param id The id of the generic gamepad
  12318. * @param index The index of the generic gamepad
  12319. * @param browserGamepad The browser gamepad
  12320. */
  12321. constructor(id: string, index: number, browserGamepad: any);
  12322. private _setButtonValue;
  12323. /**
  12324. * Updates the generic gamepad
  12325. */
  12326. update(): void;
  12327. /**
  12328. * Disposes the generic gamepad
  12329. */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module BABYLON {
  12334. interface Engine {
  12335. /**
  12336. * Creates a raw texture
  12337. * @param data defines the data to store in the texture
  12338. * @param width defines the width of the texture
  12339. * @param height defines the height of the texture
  12340. * @param format defines the format of the data
  12341. * @param generateMipMaps defines if the engine should generate the mip levels
  12342. * @param invertY defines if data must be stored with Y axis inverted
  12343. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12344. * @param compression defines the compression used (null by default)
  12345. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12346. * @returns the raw texture inside an InternalTexture
  12347. */
  12348. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12349. /**
  12350. * Update a raw texture
  12351. * @param texture defines the texture to update
  12352. * @param data defines the data to store in the texture
  12353. * @param format defines the format of the data
  12354. * @param invertY defines if data must be stored with Y axis inverted
  12355. */
  12356. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12357. /**
  12358. * Update a raw texture
  12359. * @param texture defines the texture to update
  12360. * @param data defines the data to store in the texture
  12361. * @param format defines the format of the data
  12362. * @param invertY defines if data must be stored with Y axis inverted
  12363. * @param compression defines the compression used (null by default)
  12364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12365. */
  12366. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12367. /**
  12368. * Creates a new raw cube texture
  12369. * @param data defines the array of data to use to create each face
  12370. * @param size defines the size of the textures
  12371. * @param format defines the format of the data
  12372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12373. * @param generateMipMaps defines if the engine should generate the mip levels
  12374. * @param invertY defines if data must be stored with Y axis inverted
  12375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12376. * @param compression defines the compression used (null by default)
  12377. * @returns the cube texture as an InternalTexture
  12378. */
  12379. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12380. /**
  12381. * Update a raw cube texture
  12382. * @param texture defines the texture to udpdate
  12383. * @param data defines the data to store
  12384. * @param format defines the data format
  12385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12386. * @param invertY defines if data must be stored with Y axis inverted
  12387. */
  12388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12389. /**
  12390. * Update a raw cube texture
  12391. * @param texture defines the texture to udpdate
  12392. * @param data defines the data to store
  12393. * @param format defines the data format
  12394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12395. * @param invertY defines if data must be stored with Y axis inverted
  12396. * @param compression defines the compression used (null by default)
  12397. */
  12398. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12399. /**
  12400. * Update a raw cube texture
  12401. * @param texture defines the texture to udpdate
  12402. * @param data defines the data to store
  12403. * @param format defines the data format
  12404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12405. * @param invertY defines if data must be stored with Y axis inverted
  12406. * @param compression defines the compression used (null by default)
  12407. * @param level defines which level of the texture to update
  12408. */
  12409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12410. /**
  12411. * Creates a new raw cube texture from a specified url
  12412. * @param url defines the url where the data is located
  12413. * @param scene defines the current scene
  12414. * @param size defines the size of the textures
  12415. * @param format defines the format of the data
  12416. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12417. * @param noMipmap defines if the engine should avoid generating the mip levels
  12418. * @param callback defines a callback used to extract texture data from loaded data
  12419. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12420. * @param onLoad defines a callback called when texture is loaded
  12421. * @param onError defines a callback called if there is an error
  12422. * @returns the cube texture as an InternalTexture
  12423. */
  12424. 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;
  12425. /**
  12426. * Creates a new raw cube texture from a specified url
  12427. * @param url defines the url where the data is located
  12428. * @param scene defines the current scene
  12429. * @param size defines the size of the textures
  12430. * @param format defines the format of the data
  12431. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12432. * @param noMipmap defines if the engine should avoid generating the mip levels
  12433. * @param callback defines a callback used to extract texture data from loaded data
  12434. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12435. * @param onLoad defines a callback called when texture is loaded
  12436. * @param onError defines a callback called if there is an error
  12437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @returns the cube texture as an InternalTexture
  12440. */
  12441. 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;
  12442. /**
  12443. * Creates a new raw 3D texture
  12444. * @param data defines the data used to create the texture
  12445. * @param width defines the width of the texture
  12446. * @param height defines the height of the texture
  12447. * @param depth defines the depth of the texture
  12448. * @param format defines the format of the texture
  12449. * @param generateMipMaps defines if the engine must generate mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compressed used (can be null)
  12453. * @param textureType defines the compressed used (can be null)
  12454. * @returns a new raw 3D texture (stored in an InternalTexture)
  12455. */
  12456. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12457. /**
  12458. * Update a raw 3D texture
  12459. * @param texture defines the texture to update
  12460. * @param data defines the data to store
  12461. * @param format defines the data format
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw 3D texture
  12467. * @param texture defines the texture to update
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param invertY defines if data must be stored with Y axis inverted
  12471. * @param compression defines the used compression (can be null)
  12472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12473. */
  12474. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * Raw texture can help creating a texture directly from an array of data.
  12480. * This can be super useful if you either get the data from an uncompressed source or
  12481. * if you wish to create your texture pixel by pixel.
  12482. */
  12483. export class RawTexture extends Texture {
  12484. /**
  12485. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12486. */
  12487. format: number;
  12488. private _engine;
  12489. /**
  12490. * Instantiates a new RawTexture.
  12491. * Raw texture can help creating a texture directly from an array of data.
  12492. * This can be super useful if you either get the data from an uncompressed source or
  12493. * if you wish to create your texture pixel by pixel.
  12494. * @param data define the array of data to use to create the texture
  12495. * @param width define the width of the texture
  12496. * @param height define the height of the texture
  12497. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12498. * @param scene define the scene the texture belongs to
  12499. * @param generateMipMaps define whether mip maps should be generated or not
  12500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12503. */
  12504. constructor(data: ArrayBufferView, width: number, height: number,
  12505. /**
  12506. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12507. */
  12508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12509. /**
  12510. * Updates the texture underlying data.
  12511. * @param data Define the new data of the texture
  12512. */
  12513. update(data: ArrayBufferView): void;
  12514. /**
  12515. * Creates a luminance texture from some data.
  12516. * @param data Define the texture data
  12517. * @param width Define the width of the texture
  12518. * @param height Define the height of the texture
  12519. * @param scene Define the scene the texture belongs to
  12520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12523. * @returns the luminance texture
  12524. */
  12525. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12526. /**
  12527. * Creates a luminance alpha texture from some data.
  12528. * @param data Define the texture data
  12529. * @param width Define the width of the texture
  12530. * @param height Define the height of the texture
  12531. * @param scene Define the scene the texture belongs to
  12532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12535. * @returns the luminance alpha texture
  12536. */
  12537. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12538. /**
  12539. * Creates an alpha texture from some data.
  12540. * @param data Define the texture data
  12541. * @param width Define the width of the texture
  12542. * @param height Define the height of the texture
  12543. * @param scene Define the scene the texture belongs to
  12544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12547. * @returns the alpha texture
  12548. */
  12549. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12550. /**
  12551. * Creates a RGB texture from some data.
  12552. * @param data Define the texture data
  12553. * @param width Define the width of the texture
  12554. * @param height Define the height of the texture
  12555. * @param scene Define the scene the texture belongs to
  12556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12560. * @returns the RGB alpha texture
  12561. */
  12562. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12563. /**
  12564. * Creates a RGBA texture from some data.
  12565. * @param data Define the texture data
  12566. * @param width Define the width of the texture
  12567. * @param height Define the height of the texture
  12568. * @param scene Define the scene the texture belongs to
  12569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12573. * @returns the RGBA texture
  12574. */
  12575. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12576. /**
  12577. * Creates a R texture from some data.
  12578. * @param data Define the texture data
  12579. * @param width Define the width of the texture
  12580. * @param height Define the height of the texture
  12581. * @param scene Define the scene the texture belongs to
  12582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12586. * @returns the R texture
  12587. */
  12588. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. /**
  12593. * Interface for the size containing width and height
  12594. */
  12595. export interface ISize {
  12596. /**
  12597. * Width
  12598. */
  12599. width: number;
  12600. /**
  12601. * Heighht
  12602. */
  12603. height: number;
  12604. }
  12605. /**
  12606. * Size containing widht and height
  12607. */
  12608. export class Size implements ISize {
  12609. /**
  12610. * Width
  12611. */
  12612. width: number;
  12613. /**
  12614. * Height
  12615. */
  12616. height: number;
  12617. /**
  12618. * Creates a Size object from the given width and height (floats).
  12619. * @param width width of the new size
  12620. * @param height height of the new size
  12621. */
  12622. constructor(width: number, height: number);
  12623. /**
  12624. * Returns a string with the Size width and height
  12625. * @returns a string with the Size width and height
  12626. */
  12627. toString(): string;
  12628. /**
  12629. * "Size"
  12630. * @returns the string "Size"
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Returns the Size hash code.
  12635. * @returns a hash code for a unique width and height
  12636. */
  12637. getHashCode(): number;
  12638. /**
  12639. * Updates the current size from the given one.
  12640. * @param src the given size
  12641. */
  12642. copyFrom(src: Size): void;
  12643. /**
  12644. * Updates in place the current Size from the given floats.
  12645. * @param width width of the new size
  12646. * @param height height of the new size
  12647. * @returns the updated Size.
  12648. */
  12649. copyFromFloats(width: number, height: number): Size;
  12650. /**
  12651. * Updates in place the current Size from the given floats.
  12652. * @param width width to set
  12653. * @param height height to set
  12654. * @returns the updated Size.
  12655. */
  12656. set(width: number, height: number): Size;
  12657. /**
  12658. * Multiplies the width and height by numbers
  12659. * @param w factor to multiple the width by
  12660. * @param h factor to multiple the height by
  12661. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12662. */
  12663. multiplyByFloats(w: number, h: number): Size;
  12664. /**
  12665. * Clones the size
  12666. * @returns a new Size copied from the given one.
  12667. */
  12668. clone(): Size;
  12669. /**
  12670. * True if the current Size and the given one width and height are strictly equal.
  12671. * @param other the other size to compare against
  12672. * @returns True if the current Size and the given one width and height are strictly equal.
  12673. */
  12674. equals(other: Size): boolean;
  12675. /**
  12676. * The surface of the Size : width * height (float).
  12677. */
  12678. readonly surface: number;
  12679. /**
  12680. * Create a new size of zero
  12681. * @returns a new Size set to (0.0, 0.0)
  12682. */
  12683. static Zero(): Size;
  12684. /**
  12685. * Sums the width and height of two sizes
  12686. * @param otherSize size to add to this size
  12687. * @returns a new Size set as the addition result of the current Size and the given one.
  12688. */
  12689. add(otherSize: Size): Size;
  12690. /**
  12691. * Subtracts the width and height of two
  12692. * @param otherSize size to subtract to this size
  12693. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12694. */
  12695. subtract(otherSize: Size): Size;
  12696. /**
  12697. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12698. * @param start starting size to lerp between
  12699. * @param end end size to lerp between
  12700. * @param amount amount to lerp between the start and end values
  12701. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12702. */
  12703. static Lerp(start: Size, end: Size, amount: number): Size;
  12704. }
  12705. }
  12706. declare module BABYLON {
  12707. /**
  12708. * Defines a runtime animation
  12709. */
  12710. export class RuntimeAnimation {
  12711. private _events;
  12712. /**
  12713. * The current frame of the runtime animation
  12714. */
  12715. private _currentFrame;
  12716. /**
  12717. * The animation used by the runtime animation
  12718. */
  12719. private _animation;
  12720. /**
  12721. * The target of the runtime animation
  12722. */
  12723. private _target;
  12724. /**
  12725. * The initiating animatable
  12726. */
  12727. private _host;
  12728. /**
  12729. * The original value of the runtime animation
  12730. */
  12731. private _originalValue;
  12732. /**
  12733. * The original blend value of the runtime animation
  12734. */
  12735. private _originalBlendValue;
  12736. /**
  12737. * The offsets cache of the runtime animation
  12738. */
  12739. private _offsetsCache;
  12740. /**
  12741. * The high limits cache of the runtime animation
  12742. */
  12743. private _highLimitsCache;
  12744. /**
  12745. * Specifies if the runtime animation has been stopped
  12746. */
  12747. private _stopped;
  12748. /**
  12749. * The blending factor of the runtime animation
  12750. */
  12751. private _blendingFactor;
  12752. /**
  12753. * The BabylonJS scene
  12754. */
  12755. private _scene;
  12756. /**
  12757. * The current value of the runtime animation
  12758. */
  12759. private _currentValue;
  12760. /** @hidden */
  12761. _animationState: _IAnimationState;
  12762. /**
  12763. * The active target of the runtime animation
  12764. */
  12765. private _activeTargets;
  12766. private _currentActiveTarget;
  12767. private _directTarget;
  12768. /**
  12769. * The target path of the runtime animation
  12770. */
  12771. private _targetPath;
  12772. /**
  12773. * The weight of the runtime animation
  12774. */
  12775. private _weight;
  12776. /**
  12777. * The ratio offset of the runtime animation
  12778. */
  12779. private _ratioOffset;
  12780. /**
  12781. * The previous delay of the runtime animation
  12782. */
  12783. private _previousDelay;
  12784. /**
  12785. * The previous ratio of the runtime animation
  12786. */
  12787. private _previousRatio;
  12788. private _enableBlending;
  12789. private _keys;
  12790. private _minFrame;
  12791. private _maxFrame;
  12792. private _minValue;
  12793. private _maxValue;
  12794. private _targetIsArray;
  12795. /**
  12796. * Gets the current frame of the runtime animation
  12797. */
  12798. readonly currentFrame: number;
  12799. /**
  12800. * Gets the weight of the runtime animation
  12801. */
  12802. readonly weight: number;
  12803. /**
  12804. * Gets the current value of the runtime animation
  12805. */
  12806. readonly currentValue: any;
  12807. /**
  12808. * Gets the target path of the runtime animation
  12809. */
  12810. readonly targetPath: string;
  12811. /**
  12812. * Gets the actual target of the runtime animation
  12813. */
  12814. readonly target: any;
  12815. /** @hidden */
  12816. _onLoop: () => void;
  12817. /**
  12818. * Create a new RuntimeAnimation object
  12819. * @param target defines the target of the animation
  12820. * @param animation defines the source animation object
  12821. * @param scene defines the hosting scene
  12822. * @param host defines the initiating Animatable
  12823. */
  12824. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12825. private _preparePath;
  12826. /**
  12827. * Gets the animation from the runtime animation
  12828. */
  12829. readonly animation: Animation;
  12830. /**
  12831. * Resets the runtime animation to the beginning
  12832. * @param restoreOriginal defines whether to restore the target property to the original value
  12833. */
  12834. reset(restoreOriginal?: boolean): void;
  12835. /**
  12836. * Specifies if the runtime animation is stopped
  12837. * @returns Boolean specifying if the runtime animation is stopped
  12838. */
  12839. isStopped(): boolean;
  12840. /**
  12841. * Disposes of the runtime animation
  12842. */
  12843. dispose(): void;
  12844. /**
  12845. * Apply the interpolated value to the target
  12846. * @param currentValue defines the value computed by the animation
  12847. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12848. */
  12849. setValue(currentValue: any, weight: number): void;
  12850. private _getOriginalValues;
  12851. private _setValue;
  12852. /**
  12853. * Gets the loop pmode of the runtime animation
  12854. * @returns Loop Mode
  12855. */
  12856. private _getCorrectLoopMode;
  12857. /**
  12858. * Move the current animation to a given frame
  12859. * @param frame defines the frame to move to
  12860. */
  12861. goToFrame(frame: number): void;
  12862. /**
  12863. * @hidden Internal use only
  12864. */
  12865. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12866. /**
  12867. * Execute the current animation
  12868. * @param delay defines the delay to add to the current frame
  12869. * @param from defines the lower bound of the animation range
  12870. * @param to defines the upper bound of the animation range
  12871. * @param loop defines if the current animation must loop
  12872. * @param speedRatio defines the current speed ratio
  12873. * @param weight defines the weight of the animation (default is -1 so no weight)
  12874. * @param onLoop optional callback called when animation loops
  12875. * @returns a boolean indicating if the animation is running
  12876. */
  12877. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Class used to store an actual running animation
  12883. */
  12884. export class Animatable {
  12885. /** defines the target object */
  12886. target: any;
  12887. /** defines the starting frame number (default is 0) */
  12888. fromFrame: number;
  12889. /** defines the ending frame number (default is 100) */
  12890. toFrame: number;
  12891. /** defines if the animation must loop (default is false) */
  12892. loopAnimation: boolean;
  12893. /** defines a callback to call when animation ends if it is not looping */
  12894. onAnimationEnd?: (() => void) | null | undefined;
  12895. /** defines a callback to call when animation loops */
  12896. onAnimationLoop?: (() => void) | null | undefined;
  12897. private _localDelayOffset;
  12898. private _pausedDelay;
  12899. private _runtimeAnimations;
  12900. private _paused;
  12901. private _scene;
  12902. private _speedRatio;
  12903. private _weight;
  12904. private _syncRoot;
  12905. /**
  12906. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12907. * This will only apply for non looping animation (default is true)
  12908. */
  12909. disposeOnEnd: boolean;
  12910. /**
  12911. * Gets a boolean indicating if the animation has started
  12912. */
  12913. animationStarted: boolean;
  12914. /**
  12915. * Observer raised when the animation ends
  12916. */
  12917. onAnimationEndObservable: Observable<Animatable>;
  12918. /**
  12919. * Observer raised when the animation loops
  12920. */
  12921. onAnimationLoopObservable: Observable<Animatable>;
  12922. /**
  12923. * Gets the root Animatable used to synchronize and normalize animations
  12924. */
  12925. readonly syncRoot: Nullable<Animatable>;
  12926. /**
  12927. * Gets the current frame of the first RuntimeAnimation
  12928. * Used to synchronize Animatables
  12929. */
  12930. readonly masterFrame: number;
  12931. /**
  12932. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12933. */
  12934. weight: number;
  12935. /**
  12936. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12937. */
  12938. speedRatio: number;
  12939. /**
  12940. * Creates a new Animatable
  12941. * @param scene defines the hosting scene
  12942. * @param target defines the target object
  12943. * @param fromFrame defines the starting frame number (default is 0)
  12944. * @param toFrame defines the ending frame number (default is 100)
  12945. * @param loopAnimation defines if the animation must loop (default is false)
  12946. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12947. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12948. * @param animations defines a group of animation to add to the new Animatable
  12949. * @param onAnimationLoop defines a callback to call when animation loops
  12950. */
  12951. constructor(scene: Scene,
  12952. /** defines the target object */
  12953. target: any,
  12954. /** defines the starting frame number (default is 0) */
  12955. fromFrame?: number,
  12956. /** defines the ending frame number (default is 100) */
  12957. toFrame?: number,
  12958. /** defines if the animation must loop (default is false) */
  12959. loopAnimation?: boolean, speedRatio?: number,
  12960. /** defines a callback to call when animation ends if it is not looping */
  12961. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12962. /** defines a callback to call when animation loops */
  12963. onAnimationLoop?: (() => void) | null | undefined);
  12964. /**
  12965. * Synchronize and normalize current Animatable with a source Animatable
  12966. * This is useful when using animation weights and when animations are not of the same length
  12967. * @param root defines the root Animatable to synchronize with
  12968. * @returns the current Animatable
  12969. */
  12970. syncWith(root: Animatable): Animatable;
  12971. /**
  12972. * Gets the list of runtime animations
  12973. * @returns an array of RuntimeAnimation
  12974. */
  12975. getAnimations(): RuntimeAnimation[];
  12976. /**
  12977. * Adds more animations to the current animatable
  12978. * @param target defines the target of the animations
  12979. * @param animations defines the new animations to add
  12980. */
  12981. appendAnimations(target: any, animations: Animation[]): void;
  12982. /**
  12983. * Gets the source animation for a specific property
  12984. * @param property defines the propertyu to look for
  12985. * @returns null or the source animation for the given property
  12986. */
  12987. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12988. /**
  12989. * Gets the runtime animation for a specific property
  12990. * @param property defines the propertyu to look for
  12991. * @returns null or the runtime animation for the given property
  12992. */
  12993. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12994. /**
  12995. * Resets the animatable to its original state
  12996. */
  12997. reset(): void;
  12998. /**
  12999. * Allows the animatable to blend with current running animations
  13000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13001. * @param blendingSpeed defines the blending speed to use
  13002. */
  13003. enableBlending(blendingSpeed: number): void;
  13004. /**
  13005. * Disable animation blending
  13006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13007. */
  13008. disableBlending(): void;
  13009. /**
  13010. * Jump directly to a given frame
  13011. * @param frame defines the frame to jump to
  13012. */
  13013. goToFrame(frame: number): void;
  13014. /**
  13015. * Pause the animation
  13016. */
  13017. pause(): void;
  13018. /**
  13019. * Restart the animation
  13020. */
  13021. restart(): void;
  13022. private _raiseOnAnimationEnd;
  13023. /**
  13024. * Stop and delete the current animation
  13025. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13026. * @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)
  13027. */
  13028. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13029. /**
  13030. * Wait asynchronously for the animation to end
  13031. * @returns a promise which will be fullfilled when the animation ends
  13032. */
  13033. waitAsync(): Promise<Animatable>;
  13034. /** @hidden */
  13035. _animate(delay: number): boolean;
  13036. }
  13037. interface Scene {
  13038. /** @hidden */
  13039. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13040. /** @hidden */
  13041. _processLateAnimationBindingsForMatrices(holder: {
  13042. totalWeight: number;
  13043. animations: RuntimeAnimation[];
  13044. originalValue: Matrix;
  13045. }): any;
  13046. /** @hidden */
  13047. _processLateAnimationBindingsForQuaternions(holder: {
  13048. totalWeight: number;
  13049. animations: RuntimeAnimation[];
  13050. originalValue: Quaternion;
  13051. }, refQuaternion: Quaternion): Quaternion;
  13052. /** @hidden */
  13053. _processLateAnimationBindings(): void;
  13054. /**
  13055. * Will start the animation sequence of a given target
  13056. * @param target defines the target
  13057. * @param from defines from which frame should animation start
  13058. * @param to defines until which frame should animation run.
  13059. * @param weight defines the weight to apply to the animation (1.0 by default)
  13060. * @param loop defines if the animation loops
  13061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13062. * @param onAnimationEnd defines the function to be executed when the animation ends
  13063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13064. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13065. * @param onAnimationLoop defines the callback to call when an animation loops
  13066. * @returns the animatable object created for this animation
  13067. */
  13068. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13069. /**
  13070. * Will start the animation sequence of a given target
  13071. * @param target defines the target
  13072. * @param from defines from which frame should animation start
  13073. * @param to defines until which frame should animation run.
  13074. * @param loop defines if the animation loops
  13075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13076. * @param onAnimationEnd defines the function to be executed when the animation ends
  13077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13079. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13080. * @param onAnimationLoop defines the callback to call when an animation loops
  13081. * @returns the animatable object created for this animation
  13082. */
  13083. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13084. /**
  13085. * Will start the animation sequence of a given target and its hierarchy
  13086. * @param target defines the target
  13087. * @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.
  13088. * @param from defines from which frame should animation start
  13089. * @param to defines until which frame should animation run.
  13090. * @param loop defines if the animation loops
  13091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13092. * @param onAnimationEnd defines the function to be executed when the animation ends
  13093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13095. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13096. * @param onAnimationLoop defines the callback to call when an animation loops
  13097. * @returns the list of created animatables
  13098. */
  13099. 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[];
  13100. /**
  13101. * Begin a new animation on a given node
  13102. * @param target defines the target where the animation will take place
  13103. * @param animations defines the list of animations to start
  13104. * @param from defines the initial value
  13105. * @param to defines the final value
  13106. * @param loop defines if you want animation to loop (off by default)
  13107. * @param speedRatio defines the speed ratio to apply to all animations
  13108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13109. * @param onAnimationLoop defines the callback to call when an animation loops
  13110. * @returns the list of created animatables
  13111. */
  13112. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13113. /**
  13114. * Begin a new animation on a given node and its hierarchy
  13115. * @param target defines the root node where the animation will take place
  13116. * @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.
  13117. * @param animations defines the list of animations to start
  13118. * @param from defines the initial value
  13119. * @param to defines the final value
  13120. * @param loop defines if you want animation to loop (off by default)
  13121. * @param speedRatio defines the speed ratio to apply to all animations
  13122. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13123. * @param onAnimationLoop defines the callback to call when an animation loops
  13124. * @returns the list of animatables created for all nodes
  13125. */
  13126. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13127. /**
  13128. * Gets the animatable associated with a specific target
  13129. * @param target defines the target of the animatable
  13130. * @returns the required animatable if found
  13131. */
  13132. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13133. /**
  13134. * Gets all animatables associated with a given target
  13135. * @param target defines the target to look animatables for
  13136. * @returns an array of Animatables
  13137. */
  13138. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13139. /**
  13140. * Stops and removes all animations that have been applied to the scene
  13141. */
  13142. stopAllAnimations(): void;
  13143. /**
  13144. * Gets the current delta time used by animation engine
  13145. */
  13146. deltaTime: number;
  13147. }
  13148. interface Bone {
  13149. /**
  13150. * Copy an animation range from another bone
  13151. * @param source defines the source bone
  13152. * @param rangeName defines the range name to copy
  13153. * @param frameOffset defines the frame offset
  13154. * @param rescaleAsRequired defines if rescaling must be applied if required
  13155. * @param skelDimensionsRatio defines the scaling ratio
  13156. * @returns true if operation was successful
  13157. */
  13158. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13159. }
  13160. }
  13161. declare module BABYLON {
  13162. /**
  13163. * Class used to override all child animations of a given target
  13164. */
  13165. export class AnimationPropertiesOverride {
  13166. /**
  13167. * Gets or sets a value indicating if animation blending must be used
  13168. */
  13169. enableBlending: boolean;
  13170. /**
  13171. * Gets or sets the blending speed to use when enableBlending is true
  13172. */
  13173. blendingSpeed: number;
  13174. /**
  13175. * Gets or sets the default loop mode to use
  13176. */
  13177. loopMode: number;
  13178. }
  13179. }
  13180. declare module BABYLON {
  13181. /**
  13182. * Class used to handle skinning animations
  13183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13184. */
  13185. export class Skeleton implements IAnimatable {
  13186. /** defines the skeleton name */
  13187. name: string;
  13188. /** defines the skeleton Id */
  13189. id: string;
  13190. /**
  13191. * Defines the list of child bones
  13192. */
  13193. bones: Bone[];
  13194. /**
  13195. * Defines an estimate of the dimension of the skeleton at rest
  13196. */
  13197. dimensionsAtRest: Vector3;
  13198. /**
  13199. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13200. */
  13201. needInitialSkinMatrix: boolean;
  13202. /**
  13203. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13204. */
  13205. overrideMesh: Nullable<AbstractMesh>;
  13206. /**
  13207. * Gets the list of animations attached to this skeleton
  13208. */
  13209. animations: Array<Animation>;
  13210. private _scene;
  13211. private _isDirty;
  13212. private _transformMatrices;
  13213. private _transformMatrixTexture;
  13214. private _meshesWithPoseMatrix;
  13215. private _animatables;
  13216. private _identity;
  13217. private _synchronizedWithMesh;
  13218. private _ranges;
  13219. private _lastAbsoluteTransformsUpdateId;
  13220. private _canUseTextureForBones;
  13221. private _uniqueId;
  13222. /** @hidden */
  13223. _numBonesWithLinkedTransformNode: number;
  13224. /** @hidden */
  13225. _hasWaitingData: Nullable<boolean>;
  13226. /**
  13227. * Specifies if the skeleton should be serialized
  13228. */
  13229. doNotSerialize: boolean;
  13230. private _useTextureToStoreBoneMatrices;
  13231. /**
  13232. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13233. * Please note that this option is not available if the hardware does not support it
  13234. */
  13235. useTextureToStoreBoneMatrices: boolean;
  13236. private _animationPropertiesOverride;
  13237. /**
  13238. * Gets or sets the animation properties override
  13239. */
  13240. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13241. /**
  13242. * List of inspectable custom properties (used by the Inspector)
  13243. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13244. */
  13245. inspectableCustomProperties: IInspectable[];
  13246. /**
  13247. * An observable triggered before computing the skeleton's matrices
  13248. */
  13249. onBeforeComputeObservable: Observable<Skeleton>;
  13250. /**
  13251. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13252. */
  13253. readonly isUsingTextureForMatrices: boolean;
  13254. /**
  13255. * Gets the unique ID of this skeleton
  13256. */
  13257. readonly uniqueId: number;
  13258. /**
  13259. * Creates a new skeleton
  13260. * @param name defines the skeleton name
  13261. * @param id defines the skeleton Id
  13262. * @param scene defines the hosting scene
  13263. */
  13264. constructor(
  13265. /** defines the skeleton name */
  13266. name: string,
  13267. /** defines the skeleton Id */
  13268. id: string, scene: Scene);
  13269. /**
  13270. * Gets the current object class name.
  13271. * @return the class name
  13272. */
  13273. getClassName(): string;
  13274. /**
  13275. * Returns an array containing the root bones
  13276. * @returns an array containing the root bones
  13277. */
  13278. getChildren(): Array<Bone>;
  13279. /**
  13280. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13282. * @returns a Float32Array containing matrices data
  13283. */
  13284. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13285. /**
  13286. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13287. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13288. * @returns a raw texture containing the data
  13289. */
  13290. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13291. /**
  13292. * Gets the current hosting scene
  13293. * @returns a scene object
  13294. */
  13295. getScene(): Scene;
  13296. /**
  13297. * Gets a string representing the current skeleton data
  13298. * @param fullDetails defines a boolean indicating if we want a verbose version
  13299. * @returns a string representing the current skeleton data
  13300. */
  13301. toString(fullDetails?: boolean): string;
  13302. /**
  13303. * Get bone's index searching by name
  13304. * @param name defines bone's name to search for
  13305. * @return the indice of the bone. Returns -1 if not found
  13306. */
  13307. getBoneIndexByName(name: string): number;
  13308. /**
  13309. * Creater a new animation range
  13310. * @param name defines the name of the range
  13311. * @param from defines the start key
  13312. * @param to defines the end key
  13313. */
  13314. createAnimationRange(name: string, from: number, to: number): void;
  13315. /**
  13316. * Delete a specific animation range
  13317. * @param name defines the name of the range
  13318. * @param deleteFrames defines if frames must be removed as well
  13319. */
  13320. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13321. /**
  13322. * Gets a specific animation range
  13323. * @param name defines the name of the range to look for
  13324. * @returns the requested animation range or null if not found
  13325. */
  13326. getAnimationRange(name: string): Nullable<AnimationRange>;
  13327. /**
  13328. * Gets the list of all animation ranges defined on this skeleton
  13329. * @returns an array
  13330. */
  13331. getAnimationRanges(): Nullable<AnimationRange>[];
  13332. /**
  13333. * Copy animation range from a source skeleton.
  13334. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13335. * @param source defines the source skeleton
  13336. * @param name defines the name of the range to copy
  13337. * @param rescaleAsRequired defines if rescaling must be applied if required
  13338. * @returns true if operation was successful
  13339. */
  13340. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13341. /**
  13342. * Forces the skeleton to go to rest pose
  13343. */
  13344. returnToRest(): void;
  13345. private _getHighestAnimationFrame;
  13346. /**
  13347. * Begin a specific animation range
  13348. * @param name defines the name of the range to start
  13349. * @param loop defines if looping must be turned on (false by default)
  13350. * @param speedRatio defines the speed ratio to apply (1 by default)
  13351. * @param onAnimationEnd defines a callback which will be called when animation will end
  13352. * @returns a new animatable
  13353. */
  13354. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13355. /** @hidden */
  13356. _markAsDirty(): void;
  13357. /** @hidden */
  13358. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13359. /** @hidden */
  13360. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13361. private _computeTransformMatrices;
  13362. /**
  13363. * Build all resources required to render a skeleton
  13364. */
  13365. prepare(): void;
  13366. /**
  13367. * Gets the list of animatables currently running for this skeleton
  13368. * @returns an array of animatables
  13369. */
  13370. getAnimatables(): IAnimatable[];
  13371. /**
  13372. * Clone the current skeleton
  13373. * @param name defines the name of the new skeleton
  13374. * @param id defines the id of the new skeleton
  13375. * @returns the new skeleton
  13376. */
  13377. clone(name: string, id?: string): Skeleton;
  13378. /**
  13379. * Enable animation blending for this skeleton
  13380. * @param blendingSpeed defines the blending speed to apply
  13381. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13382. */
  13383. enableBlending(blendingSpeed?: number): void;
  13384. /**
  13385. * Releases all resources associated with the current skeleton
  13386. */
  13387. dispose(): void;
  13388. /**
  13389. * Serialize the skeleton in a JSON object
  13390. * @returns a JSON object
  13391. */
  13392. serialize(): any;
  13393. /**
  13394. * Creates a new skeleton from serialized data
  13395. * @param parsedSkeleton defines the serialized data
  13396. * @param scene defines the hosting scene
  13397. * @returns a new skeleton
  13398. */
  13399. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13400. /**
  13401. * Compute all node absolute transforms
  13402. * @param forceUpdate defines if computation must be done even if cache is up to date
  13403. */
  13404. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13405. /**
  13406. * Gets the root pose matrix
  13407. * @returns a matrix
  13408. */
  13409. getPoseMatrix(): Nullable<Matrix>;
  13410. /**
  13411. * Sorts bones per internal index
  13412. */
  13413. sortBones(): void;
  13414. private _sortBones;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * Class used to store bone information
  13420. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13421. */
  13422. export class Bone extends Node {
  13423. /**
  13424. * defines the bone name
  13425. */
  13426. name: string;
  13427. private static _tmpVecs;
  13428. private static _tmpQuat;
  13429. private static _tmpMats;
  13430. /**
  13431. * Gets the list of child bones
  13432. */
  13433. children: Bone[];
  13434. /** Gets the animations associated with this bone */
  13435. animations: Animation[];
  13436. /**
  13437. * Gets or sets bone length
  13438. */
  13439. length: number;
  13440. /**
  13441. * @hidden Internal only
  13442. * Set this value to map this bone to a different index in the transform matrices
  13443. * Set this value to -1 to exclude the bone from the transform matrices
  13444. */
  13445. _index: Nullable<number>;
  13446. private _skeleton;
  13447. private _localMatrix;
  13448. private _restPose;
  13449. private _baseMatrix;
  13450. private _absoluteTransform;
  13451. private _invertedAbsoluteTransform;
  13452. private _parent;
  13453. private _scalingDeterminant;
  13454. private _worldTransform;
  13455. private _localScaling;
  13456. private _localRotation;
  13457. private _localPosition;
  13458. private _needToDecompose;
  13459. private _needToCompose;
  13460. /** @hidden */
  13461. _linkedTransformNode: Nullable<TransformNode>;
  13462. /** @hidden */
  13463. _waitingTransformNodeId: Nullable<string>;
  13464. /** @hidden */
  13465. /** @hidden */
  13466. _matrix: Matrix;
  13467. /**
  13468. * Create a new bone
  13469. * @param name defines the bone name
  13470. * @param skeleton defines the parent skeleton
  13471. * @param parentBone defines the parent (can be null if the bone is the root)
  13472. * @param localMatrix defines the local matrix
  13473. * @param restPose defines the rest pose matrix
  13474. * @param baseMatrix defines the base matrix
  13475. * @param index defines index of the bone in the hiearchy
  13476. */
  13477. constructor(
  13478. /**
  13479. * defines the bone name
  13480. */
  13481. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13482. /**
  13483. * Gets the current object class name.
  13484. * @return the class name
  13485. */
  13486. getClassName(): string;
  13487. /**
  13488. * Gets the parent skeleton
  13489. * @returns a skeleton
  13490. */
  13491. getSkeleton(): Skeleton;
  13492. /**
  13493. * Gets parent bone
  13494. * @returns a bone or null if the bone is the root of the bone hierarchy
  13495. */
  13496. getParent(): Nullable<Bone>;
  13497. /**
  13498. * Returns an array containing the root bones
  13499. * @returns an array containing the root bones
  13500. */
  13501. getChildren(): Array<Bone>;
  13502. /**
  13503. * Gets the node index in matrix array generated for rendering
  13504. * @returns the node index
  13505. */
  13506. getIndex(): number;
  13507. /**
  13508. * Sets the parent bone
  13509. * @param parent defines the parent (can be null if the bone is the root)
  13510. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13511. */
  13512. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13513. /**
  13514. * Gets the local matrix
  13515. * @returns a matrix
  13516. */
  13517. getLocalMatrix(): Matrix;
  13518. /**
  13519. * Gets the base matrix (initial matrix which remains unchanged)
  13520. * @returns a matrix
  13521. */
  13522. getBaseMatrix(): Matrix;
  13523. /**
  13524. * Gets the rest pose matrix
  13525. * @returns a matrix
  13526. */
  13527. getRestPose(): Matrix;
  13528. /**
  13529. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13530. */
  13531. getWorldMatrix(): Matrix;
  13532. /**
  13533. * Sets the local matrix to rest pose matrix
  13534. */
  13535. returnToRest(): void;
  13536. /**
  13537. * Gets the inverse of the absolute transform matrix.
  13538. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13539. * @returns a matrix
  13540. */
  13541. getInvertedAbsoluteTransform(): Matrix;
  13542. /**
  13543. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13544. * @returns a matrix
  13545. */
  13546. getAbsoluteTransform(): Matrix;
  13547. /**
  13548. * Links with the given transform node.
  13549. * The local matrix of this bone is copied from the transform node every frame.
  13550. * @param transformNode defines the transform node to link to
  13551. */
  13552. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13553. /**
  13554. * Gets the node used to drive the bone's transformation
  13555. * @returns a transform node or null
  13556. */
  13557. getTransformNode(): Nullable<TransformNode>;
  13558. /** Gets or sets current position (in local space) */
  13559. position: Vector3;
  13560. /** Gets or sets current rotation (in local space) */
  13561. rotation: Vector3;
  13562. /** Gets or sets current rotation quaternion (in local space) */
  13563. rotationQuaternion: Quaternion;
  13564. /** Gets or sets current scaling (in local space) */
  13565. scaling: Vector3;
  13566. /**
  13567. * Gets the animation properties override
  13568. */
  13569. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13570. private _decompose;
  13571. private _compose;
  13572. /**
  13573. * Update the base and local matrices
  13574. * @param matrix defines the new base or local matrix
  13575. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13576. * @param updateLocalMatrix defines if the local matrix should be updated
  13577. */
  13578. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13579. /** @hidden */
  13580. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13581. /**
  13582. * Flag the bone as dirty (Forcing it to update everything)
  13583. */
  13584. markAsDirty(): void;
  13585. /** @hidden */
  13586. _markAsDirtyAndCompose(): void;
  13587. private _markAsDirtyAndDecompose;
  13588. /**
  13589. * Translate the bone in local or world space
  13590. * @param vec The amount to translate the bone
  13591. * @param space The space that the translation is in
  13592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13593. */
  13594. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13595. /**
  13596. * Set the postion of the bone in local or world space
  13597. * @param position The position to set the bone
  13598. * @param space The space that the position is in
  13599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13600. */
  13601. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13602. /**
  13603. * Set the absolute position of the bone (world space)
  13604. * @param position The position to set the bone
  13605. * @param mesh The mesh that this bone is attached to
  13606. */
  13607. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13608. /**
  13609. * Scale the bone on the x, y and z axes (in local space)
  13610. * @param x The amount to scale the bone on the x axis
  13611. * @param y The amount to scale the bone on the y axis
  13612. * @param z The amount to scale the bone on the z axis
  13613. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13614. */
  13615. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13616. /**
  13617. * Set the bone scaling in local space
  13618. * @param scale defines the scaling vector
  13619. */
  13620. setScale(scale: Vector3): void;
  13621. /**
  13622. * Gets the current scaling in local space
  13623. * @returns the current scaling vector
  13624. */
  13625. getScale(): Vector3;
  13626. /**
  13627. * Gets the current scaling in local space and stores it in a target vector
  13628. * @param result defines the target vector
  13629. */
  13630. getScaleToRef(result: Vector3): void;
  13631. /**
  13632. * Set the yaw, pitch, and roll of the bone in local or world space
  13633. * @param yaw The rotation of the bone on the y axis
  13634. * @param pitch The rotation of the bone on the x axis
  13635. * @param roll The rotation of the bone on the z axis
  13636. * @param space The space that the axes of rotation are in
  13637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13638. */
  13639. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13640. /**
  13641. * Add a rotation to the bone on an axis in local or world space
  13642. * @param axis The axis to rotate the bone on
  13643. * @param amount The amount to rotate the bone
  13644. * @param space The space that the axis is in
  13645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13646. */
  13647. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13648. /**
  13649. * Set the rotation of the bone to a particular axis angle in local or world space
  13650. * @param axis The axis to rotate the bone on
  13651. * @param angle The angle that the bone should be rotated to
  13652. * @param space The space that the axis is in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. */
  13655. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13656. /**
  13657. * Set the euler rotation of the bone in local of world space
  13658. * @param rotation The euler rotation that the bone should be set to
  13659. * @param space The space that the rotation is in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. */
  13662. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13663. /**
  13664. * Set the quaternion rotation of the bone in local of world space
  13665. * @param quat The quaternion rotation that the bone should be set to
  13666. * @param space The space that the rotation is in
  13667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13668. */
  13669. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13670. /**
  13671. * Set the rotation matrix of the bone in local of world space
  13672. * @param rotMat The rotation matrix that the bone should be set to
  13673. * @param space The space that the rotation is in
  13674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13675. */
  13676. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13677. private _rotateWithMatrix;
  13678. private _getNegativeRotationToRef;
  13679. /**
  13680. * Get the position of the bone in local or world space
  13681. * @param space The space that the returned position is in
  13682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13683. * @returns The position of the bone
  13684. */
  13685. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13686. /**
  13687. * Copy the position of the bone to a vector3 in local or world space
  13688. * @param space The space that the returned position is in
  13689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13690. * @param result The vector3 to copy the position to
  13691. */
  13692. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13693. /**
  13694. * Get the absolute position of the bone (world space)
  13695. * @param mesh The mesh that this bone is attached to
  13696. * @returns The absolute position of the bone
  13697. */
  13698. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13699. /**
  13700. * Copy the absolute position of the bone (world space) to the result param
  13701. * @param mesh The mesh that this bone is attached to
  13702. * @param result The vector3 to copy the absolute position to
  13703. */
  13704. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13705. /**
  13706. * Compute the absolute transforms of this bone and its children
  13707. */
  13708. computeAbsoluteTransforms(): void;
  13709. /**
  13710. * Get the world direction from an axis that is in the local space of the bone
  13711. * @param localAxis The local direction that is used to compute the world direction
  13712. * @param mesh The mesh that this bone is attached to
  13713. * @returns The world direction
  13714. */
  13715. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13716. /**
  13717. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13718. * @param localAxis The local direction that is used to compute the world direction
  13719. * @param mesh The mesh that this bone is attached to
  13720. * @param result The vector3 that the world direction will be copied to
  13721. */
  13722. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13723. /**
  13724. * Get the euler rotation of the bone in local or world space
  13725. * @param space The space that the rotation should be in
  13726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13727. * @returns The euler rotation
  13728. */
  13729. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13730. /**
  13731. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13732. * @param space The space that the rotation should be in
  13733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13734. * @param result The vector3 that the rotation should be copied to
  13735. */
  13736. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13737. /**
  13738. * Get the quaternion rotation of the bone in either local or world space
  13739. * @param space The space that the rotation should be in
  13740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13741. * @returns The quaternion rotation
  13742. */
  13743. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13744. /**
  13745. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13746. * @param space The space that the rotation should be in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. * @param result The quaternion that the rotation should be copied to
  13749. */
  13750. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13751. /**
  13752. * Get the rotation matrix of the bone in local or world space
  13753. * @param space The space that the rotation should be in
  13754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13755. * @returns The rotation matrix
  13756. */
  13757. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13758. /**
  13759. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13760. * @param space The space that the rotation should be in
  13761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13762. * @param result The quaternion that the rotation should be copied to
  13763. */
  13764. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13765. /**
  13766. * Get the world position of a point that is in the local space of the bone
  13767. * @param position The local position
  13768. * @param mesh The mesh that this bone is attached to
  13769. * @returns The world position
  13770. */
  13771. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13772. /**
  13773. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13774. * @param position The local position
  13775. * @param mesh The mesh that this bone is attached to
  13776. * @param result The vector3 that the world position should be copied to
  13777. */
  13778. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13779. /**
  13780. * Get the local position of a point that is in world space
  13781. * @param position The world position
  13782. * @param mesh The mesh that this bone is attached to
  13783. * @returns The local position
  13784. */
  13785. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13786. /**
  13787. * Get the local position of a point that is in world space and copy it to the result param
  13788. * @param position The world position
  13789. * @param mesh The mesh that this bone is attached to
  13790. * @param result The vector3 that the local position should be copied to
  13791. */
  13792. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13793. }
  13794. }
  13795. declare module BABYLON {
  13796. /**
  13797. * 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.
  13798. * @see https://doc.babylonjs.com/how_to/transformnode
  13799. */
  13800. export class TransformNode extends Node {
  13801. /**
  13802. * Object will not rotate to face the camera
  13803. */
  13804. static BILLBOARDMODE_NONE: number;
  13805. /**
  13806. * Object will rotate to face the camera but only on the x axis
  13807. */
  13808. static BILLBOARDMODE_X: number;
  13809. /**
  13810. * Object will rotate to face the camera but only on the y axis
  13811. */
  13812. static BILLBOARDMODE_Y: number;
  13813. /**
  13814. * Object will rotate to face the camera but only on the z axis
  13815. */
  13816. static BILLBOARDMODE_Z: number;
  13817. /**
  13818. * Object will rotate to face the camera
  13819. */
  13820. static BILLBOARDMODE_ALL: number;
  13821. /**
  13822. * Object will rotate to face the camera's position instead of orientation
  13823. */
  13824. static BILLBOARDMODE_USE_POSITION: number;
  13825. private _forward;
  13826. private _forwardInverted;
  13827. private _up;
  13828. private _right;
  13829. private _rightInverted;
  13830. private _position;
  13831. private _rotation;
  13832. private _rotationQuaternion;
  13833. protected _scaling: Vector3;
  13834. protected _isDirty: boolean;
  13835. private _transformToBoneReferal;
  13836. private _isAbsoluteSynced;
  13837. private _billboardMode;
  13838. /**
  13839. * Gets or sets the billboard mode. Default is 0.
  13840. *
  13841. * | Value | Type | Description |
  13842. * | --- | --- | --- |
  13843. * | 0 | BILLBOARDMODE_NONE | |
  13844. * | 1 | BILLBOARDMODE_X | |
  13845. * | 2 | BILLBOARDMODE_Y | |
  13846. * | 4 | BILLBOARDMODE_Z | |
  13847. * | 7 | BILLBOARDMODE_ALL | |
  13848. *
  13849. */
  13850. billboardMode: number;
  13851. private _preserveParentRotationForBillboard;
  13852. /**
  13853. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13854. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13855. */
  13856. preserveParentRotationForBillboard: boolean;
  13857. /**
  13858. * 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
  13859. */
  13860. scalingDeterminant: number;
  13861. private _infiniteDistance;
  13862. /**
  13863. * Gets or sets the distance of the object to max, often used by skybox
  13864. */
  13865. infiniteDistance: boolean;
  13866. /**
  13867. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13868. * By default the system will update normals to compensate
  13869. */
  13870. ignoreNonUniformScaling: boolean;
  13871. /**
  13872. * 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
  13873. */
  13874. reIntegrateRotationIntoRotationQuaternion: boolean;
  13875. /** @hidden */
  13876. _poseMatrix: Nullable<Matrix>;
  13877. /** @hidden */
  13878. _localMatrix: Matrix;
  13879. private _usePivotMatrix;
  13880. private _absolutePosition;
  13881. private _absoluteScaling;
  13882. private _absoluteRotationQuaternion;
  13883. private _pivotMatrix;
  13884. private _pivotMatrixInverse;
  13885. protected _postMultiplyPivotMatrix: boolean;
  13886. protected _isWorldMatrixFrozen: boolean;
  13887. /** @hidden */
  13888. _indexInSceneTransformNodesArray: number;
  13889. /**
  13890. * An event triggered after the world matrix is updated
  13891. */
  13892. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13893. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13894. /**
  13895. * Gets a string identifying the name of the class
  13896. * @returns "TransformNode" string
  13897. */
  13898. getClassName(): string;
  13899. /**
  13900. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13901. */
  13902. position: Vector3;
  13903. /**
  13904. * 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)).
  13905. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13906. */
  13907. rotation: Vector3;
  13908. /**
  13909. * 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)).
  13910. */
  13911. scaling: Vector3;
  13912. /**
  13913. * 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).
  13914. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13915. */
  13916. rotationQuaternion: Nullable<Quaternion>;
  13917. /**
  13918. * The forward direction of that transform in world space.
  13919. */
  13920. readonly forward: Vector3;
  13921. /**
  13922. * The up direction of that transform in world space.
  13923. */
  13924. readonly up: Vector3;
  13925. /**
  13926. * The right direction of that transform in world space.
  13927. */
  13928. readonly right: Vector3;
  13929. /**
  13930. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13931. * @param matrix the matrix to copy the pose from
  13932. * @returns this TransformNode.
  13933. */
  13934. updatePoseMatrix(matrix: Matrix): TransformNode;
  13935. /**
  13936. * Returns the mesh Pose matrix.
  13937. * @returns the pose matrix
  13938. */
  13939. getPoseMatrix(): Matrix;
  13940. /** @hidden */
  13941. _isSynchronized(): boolean;
  13942. /** @hidden */
  13943. _initCache(): void;
  13944. /**
  13945. * Flag the transform node as dirty (Forcing it to update everything)
  13946. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13947. * @returns this transform node
  13948. */
  13949. markAsDirty(property: string): TransformNode;
  13950. /**
  13951. * Returns the current mesh absolute position.
  13952. * Returns a Vector3.
  13953. */
  13954. readonly absolutePosition: Vector3;
  13955. /**
  13956. * Returns the current mesh absolute scaling.
  13957. * Returns a Vector3.
  13958. */
  13959. readonly absoluteScaling: Vector3;
  13960. /**
  13961. * Returns the current mesh absolute rotation.
  13962. * Returns a Quaternion.
  13963. */
  13964. readonly absoluteRotationQuaternion: Quaternion;
  13965. /**
  13966. * Sets a new matrix to apply before all other transformation
  13967. * @param matrix defines the transform matrix
  13968. * @returns the current TransformNode
  13969. */
  13970. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13971. /**
  13972. * Sets a new pivot matrix to the current node
  13973. * @param matrix defines the new pivot matrix to use
  13974. * @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
  13975. * @returns the current TransformNode
  13976. */
  13977. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13978. /**
  13979. * Returns the mesh pivot matrix.
  13980. * Default : Identity.
  13981. * @returns the matrix
  13982. */
  13983. getPivotMatrix(): Matrix;
  13984. /**
  13985. * Instantiate (when possible) or clone that node with its hierarchy
  13986. * @param newParent defines the new parent to use for the instance (or clone)
  13987. * @param options defines options to configure how copy is done
  13988. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13989. * @returns an instance (or a clone) of the current node with its hiearchy
  13990. */
  13991. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13992. doNotInstantiate: boolean;
  13993. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13994. /**
  13995. * Prevents the World matrix to be computed any longer
  13996. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13997. * @returns the TransformNode.
  13998. */
  13999. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14000. /**
  14001. * Allows back the World matrix computation.
  14002. * @returns the TransformNode.
  14003. */
  14004. unfreezeWorldMatrix(): this;
  14005. /**
  14006. * True if the World matrix has been frozen.
  14007. */
  14008. readonly isWorldMatrixFrozen: boolean;
  14009. /**
  14010. * Retuns the mesh absolute position in the World.
  14011. * @returns a Vector3.
  14012. */
  14013. getAbsolutePosition(): Vector3;
  14014. /**
  14015. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14016. * @param absolutePosition the absolute position to set
  14017. * @returns the TransformNode.
  14018. */
  14019. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14020. /**
  14021. * Sets the mesh position in its local space.
  14022. * @param vector3 the position to set in localspace
  14023. * @returns the TransformNode.
  14024. */
  14025. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14026. /**
  14027. * Returns the mesh position in the local space from the current World matrix values.
  14028. * @returns a new Vector3.
  14029. */
  14030. getPositionExpressedInLocalSpace(): Vector3;
  14031. /**
  14032. * Translates the mesh along the passed Vector3 in its local space.
  14033. * @param vector3 the distance to translate in localspace
  14034. * @returns the TransformNode.
  14035. */
  14036. locallyTranslate(vector3: Vector3): TransformNode;
  14037. private static _lookAtVectorCache;
  14038. /**
  14039. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14040. * @param targetPoint the position (must be in same space as current mesh) to look at
  14041. * @param yawCor optional yaw (y-axis) correction in radians
  14042. * @param pitchCor optional pitch (x-axis) correction in radians
  14043. * @param rollCor optional roll (z-axis) correction in radians
  14044. * @param space the choosen space of the target
  14045. * @returns the TransformNode.
  14046. */
  14047. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14048. /**
  14049. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14050. * This Vector3 is expressed in the World space.
  14051. * @param localAxis axis to rotate
  14052. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14053. */
  14054. getDirection(localAxis: Vector3): Vector3;
  14055. /**
  14056. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14057. * localAxis is expressed in the mesh local space.
  14058. * result is computed in the Wordl space from the mesh World matrix.
  14059. * @param localAxis axis to rotate
  14060. * @param result the resulting transformnode
  14061. * @returns this TransformNode.
  14062. */
  14063. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14064. /**
  14065. * Sets this transform node rotation to the given local axis.
  14066. * @param localAxis the axis in local space
  14067. * @param yawCor optional yaw (y-axis) correction in radians
  14068. * @param pitchCor optional pitch (x-axis) correction in radians
  14069. * @param rollCor optional roll (z-axis) correction in radians
  14070. * @returns this TransformNode
  14071. */
  14072. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14073. /**
  14074. * Sets a new pivot point to the current node
  14075. * @param point defines the new pivot point to use
  14076. * @param space defines if the point is in world or local space (local by default)
  14077. * @returns the current TransformNode
  14078. */
  14079. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14080. /**
  14081. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14082. * @returns the pivot point
  14083. */
  14084. getPivotPoint(): Vector3;
  14085. /**
  14086. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14087. * @param result the vector3 to store the result
  14088. * @returns this TransformNode.
  14089. */
  14090. getPivotPointToRef(result: Vector3): TransformNode;
  14091. /**
  14092. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14093. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14094. */
  14095. getAbsolutePivotPoint(): Vector3;
  14096. /**
  14097. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14098. * @param result vector3 to store the result
  14099. * @returns this TransformNode.
  14100. */
  14101. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14102. /**
  14103. * Defines the passed node as the parent of the current node.
  14104. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14105. * @see https://doc.babylonjs.com/how_to/parenting
  14106. * @param node the node ot set as the parent
  14107. * @returns this TransformNode.
  14108. */
  14109. setParent(node: Nullable<Node>): TransformNode;
  14110. private _nonUniformScaling;
  14111. /**
  14112. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14113. */
  14114. readonly nonUniformScaling: boolean;
  14115. /** @hidden */
  14116. _updateNonUniformScalingState(value: boolean): boolean;
  14117. /**
  14118. * Attach the current TransformNode to another TransformNode associated with a bone
  14119. * @param bone Bone affecting the TransformNode
  14120. * @param affectedTransformNode TransformNode associated with the bone
  14121. * @returns this object
  14122. */
  14123. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14124. /**
  14125. * Detach the transform node if its associated with a bone
  14126. * @returns this object
  14127. */
  14128. detachFromBone(): TransformNode;
  14129. private static _rotationAxisCache;
  14130. /**
  14131. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14133. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14134. * The passed axis is also normalized.
  14135. * @param axis the axis to rotate around
  14136. * @param amount the amount to rotate in radians
  14137. * @param space Space to rotate in (Default: local)
  14138. * @returns the TransformNode.
  14139. */
  14140. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14141. /**
  14142. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14143. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14144. * The passed axis is also normalized. .
  14145. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14146. * @param point the point to rotate around
  14147. * @param axis the axis to rotate around
  14148. * @param amount the amount to rotate in radians
  14149. * @returns the TransformNode
  14150. */
  14151. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14152. /**
  14153. * Translates the mesh along the axis vector for the passed distance in the given space.
  14154. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14155. * @param axis the axis to translate in
  14156. * @param distance the distance to translate
  14157. * @param space Space to rotate in (Default: local)
  14158. * @returns the TransformNode.
  14159. */
  14160. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14161. /**
  14162. * Adds a rotation step to the mesh current rotation.
  14163. * x, y, z are Euler angles expressed in radians.
  14164. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14165. * This means this rotation is made in the mesh local space only.
  14166. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14167. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14168. * ```javascript
  14169. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14170. * ```
  14171. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14172. * 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.
  14173. * @param x Rotation to add
  14174. * @param y Rotation to add
  14175. * @param z Rotation to add
  14176. * @returns the TransformNode.
  14177. */
  14178. addRotation(x: number, y: number, z: number): TransformNode;
  14179. /**
  14180. * @hidden
  14181. */
  14182. protected _getEffectiveParent(): Nullable<Node>;
  14183. /**
  14184. * Computes the world matrix of the node
  14185. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14186. * @returns the world matrix
  14187. */
  14188. computeWorldMatrix(force?: boolean): Matrix;
  14189. protected _afterComputeWorldMatrix(): void;
  14190. /**
  14191. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14192. * @param func callback function to add
  14193. *
  14194. * @returns the TransformNode.
  14195. */
  14196. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14197. /**
  14198. * Removes a registered callback function.
  14199. * @param func callback function to remove
  14200. * @returns the TransformNode.
  14201. */
  14202. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14203. /**
  14204. * Gets the position of the current mesh in camera space
  14205. * @param camera defines the camera to use
  14206. * @returns a position
  14207. */
  14208. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14209. /**
  14210. * Returns the distance from the mesh to the active camera
  14211. * @param camera defines the camera to use
  14212. * @returns the distance
  14213. */
  14214. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14215. /**
  14216. * Clone the current transform node
  14217. * @param name Name of the new clone
  14218. * @param newParent New parent for the clone
  14219. * @param doNotCloneChildren Do not clone children hierarchy
  14220. * @returns the new transform node
  14221. */
  14222. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14223. /**
  14224. * Serializes the objects information.
  14225. * @param currentSerializationObject defines the object to serialize in
  14226. * @returns the serialized object
  14227. */
  14228. serialize(currentSerializationObject?: any): any;
  14229. /**
  14230. * Returns a new TransformNode object parsed from the source provided.
  14231. * @param parsedTransformNode is the source.
  14232. * @param scene the scne the object belongs to
  14233. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14234. * @returns a new TransformNode object parsed from the source provided.
  14235. */
  14236. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14237. /**
  14238. * Get all child-transformNodes of this node
  14239. * @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
  14240. * @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
  14241. * @returns an array of TransformNode
  14242. */
  14243. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14244. /**
  14245. * Releases resources associated with this transform node.
  14246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14248. */
  14249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14250. /**
  14251. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14252. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14253. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14254. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14255. * @returns the current mesh
  14256. */
  14257. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14258. private _syncAbsoluteScalingAndRotation;
  14259. }
  14260. }
  14261. declare module BABYLON {
  14262. /**
  14263. * Defines the types of pose enabled controllers that are supported
  14264. */
  14265. export enum PoseEnabledControllerType {
  14266. /**
  14267. * HTC Vive
  14268. */
  14269. VIVE = 0,
  14270. /**
  14271. * Oculus Rift
  14272. */
  14273. OCULUS = 1,
  14274. /**
  14275. * Windows mixed reality
  14276. */
  14277. WINDOWS = 2,
  14278. /**
  14279. * Samsung gear VR
  14280. */
  14281. GEAR_VR = 3,
  14282. /**
  14283. * Google Daydream
  14284. */
  14285. DAYDREAM = 4,
  14286. /**
  14287. * Generic
  14288. */
  14289. GENERIC = 5
  14290. }
  14291. /**
  14292. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14293. */
  14294. export interface MutableGamepadButton {
  14295. /**
  14296. * Value of the button/trigger
  14297. */
  14298. value: number;
  14299. /**
  14300. * If the button/trigger is currently touched
  14301. */
  14302. touched: boolean;
  14303. /**
  14304. * If the button/trigger is currently pressed
  14305. */
  14306. pressed: boolean;
  14307. }
  14308. /**
  14309. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14310. * @hidden
  14311. */
  14312. export interface ExtendedGamepadButton extends GamepadButton {
  14313. /**
  14314. * If the button/trigger is currently pressed
  14315. */
  14316. readonly pressed: boolean;
  14317. /**
  14318. * If the button/trigger is currently touched
  14319. */
  14320. readonly touched: boolean;
  14321. /**
  14322. * Value of the button/trigger
  14323. */
  14324. readonly value: number;
  14325. }
  14326. /** @hidden */
  14327. export interface _GamePadFactory {
  14328. /**
  14329. * Returns wether or not the current gamepad can be created for this type of controller.
  14330. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14331. * @returns true if it can be created, otherwise false
  14332. */
  14333. canCreate(gamepadInfo: any): boolean;
  14334. /**
  14335. * Creates a new instance of the Gamepad.
  14336. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14337. * @returns the new gamepad instance
  14338. */
  14339. create(gamepadInfo: any): Gamepad;
  14340. }
  14341. /**
  14342. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14343. */
  14344. export class PoseEnabledControllerHelper {
  14345. /** @hidden */
  14346. static _ControllerFactories: _GamePadFactory[];
  14347. /** @hidden */
  14348. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14349. /**
  14350. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14351. * @param vrGamepad the gamepad to initialized
  14352. * @returns a vr controller of the type the gamepad identified as
  14353. */
  14354. static InitiateController(vrGamepad: any): Gamepad;
  14355. }
  14356. /**
  14357. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14358. */
  14359. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14360. /**
  14361. * If the controller is used in a webXR session
  14362. */
  14363. isXR: boolean;
  14364. private _deviceRoomPosition;
  14365. private _deviceRoomRotationQuaternion;
  14366. /**
  14367. * The device position in babylon space
  14368. */
  14369. devicePosition: Vector3;
  14370. /**
  14371. * The device rotation in babylon space
  14372. */
  14373. deviceRotationQuaternion: Quaternion;
  14374. /**
  14375. * The scale factor of the device in babylon space
  14376. */
  14377. deviceScaleFactor: number;
  14378. /**
  14379. * (Likely devicePosition should be used instead) The device position in its room space
  14380. */
  14381. position: Vector3;
  14382. /**
  14383. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14384. */
  14385. rotationQuaternion: Quaternion;
  14386. /**
  14387. * The type of controller (Eg. Windows mixed reality)
  14388. */
  14389. controllerType: PoseEnabledControllerType;
  14390. protected _calculatedPosition: Vector3;
  14391. private _calculatedRotation;
  14392. /**
  14393. * The raw pose from the device
  14394. */
  14395. rawPose: DevicePose;
  14396. private _trackPosition;
  14397. private _maxRotationDistFromHeadset;
  14398. private _draggedRoomRotation;
  14399. /**
  14400. * @hidden
  14401. */
  14402. _disableTrackPosition(fixedPosition: Vector3): void;
  14403. /**
  14404. * Internal, the mesh attached to the controller
  14405. * @hidden
  14406. */
  14407. _mesh: Nullable<AbstractMesh>;
  14408. private _poseControlledCamera;
  14409. private _leftHandSystemQuaternion;
  14410. /**
  14411. * Internal, matrix used to convert room space to babylon space
  14412. * @hidden
  14413. */
  14414. _deviceToWorld: Matrix;
  14415. /**
  14416. * Node to be used when casting a ray from the controller
  14417. * @hidden
  14418. */
  14419. _pointingPoseNode: Nullable<TransformNode>;
  14420. /**
  14421. * Name of the child mesh that can be used to cast a ray from the controller
  14422. */
  14423. static readonly POINTING_POSE: string;
  14424. /**
  14425. * Creates a new PoseEnabledController from a gamepad
  14426. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14427. */
  14428. constructor(browserGamepad: any);
  14429. private _workingMatrix;
  14430. /**
  14431. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14432. */
  14433. update(): void;
  14434. /**
  14435. * Updates only the pose device and mesh without doing any button event checking
  14436. */
  14437. protected _updatePoseAndMesh(): void;
  14438. /**
  14439. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14440. * @param poseData raw pose fromthe device
  14441. */
  14442. updateFromDevice(poseData: DevicePose): void;
  14443. /**
  14444. * @hidden
  14445. */
  14446. _meshAttachedObservable: Observable<AbstractMesh>;
  14447. /**
  14448. * Attaches a mesh to the controller
  14449. * @param mesh the mesh to be attached
  14450. */
  14451. attachToMesh(mesh: AbstractMesh): void;
  14452. /**
  14453. * Attaches the controllers mesh to a camera
  14454. * @param camera the camera the mesh should be attached to
  14455. */
  14456. attachToPoseControlledCamera(camera: TargetCamera): void;
  14457. /**
  14458. * Disposes of the controller
  14459. */
  14460. dispose(): void;
  14461. /**
  14462. * The mesh that is attached to the controller
  14463. */
  14464. readonly mesh: Nullable<AbstractMesh>;
  14465. /**
  14466. * Gets the ray of the controller in the direction the controller is pointing
  14467. * @param length the length the resulting ray should be
  14468. * @returns a ray in the direction the controller is pointing
  14469. */
  14470. getForwardRay(length?: number): Ray;
  14471. }
  14472. }
  14473. declare module BABYLON {
  14474. /**
  14475. * Defines the WebVRController object that represents controllers tracked in 3D space
  14476. */
  14477. export abstract class WebVRController extends PoseEnabledController {
  14478. /**
  14479. * Internal, the default controller model for the controller
  14480. */
  14481. protected _defaultModel: Nullable<AbstractMesh>;
  14482. /**
  14483. * Fired when the trigger state has changed
  14484. */
  14485. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14486. /**
  14487. * Fired when the main button state has changed
  14488. */
  14489. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14490. /**
  14491. * Fired when the secondary button state has changed
  14492. */
  14493. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14494. /**
  14495. * Fired when the pad state has changed
  14496. */
  14497. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14498. /**
  14499. * Fired when controllers stick values have changed
  14500. */
  14501. onPadValuesChangedObservable: Observable<StickValues>;
  14502. /**
  14503. * Array of button availible on the controller
  14504. */
  14505. protected _buttons: Array<MutableGamepadButton>;
  14506. private _onButtonStateChange;
  14507. /**
  14508. * Fired when a controller button's state has changed
  14509. * @param callback the callback containing the button that was modified
  14510. */
  14511. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14512. /**
  14513. * X and Y axis corresponding to the controllers joystick
  14514. */
  14515. pad: StickValues;
  14516. /**
  14517. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14518. */
  14519. hand: string;
  14520. /**
  14521. * The default controller model for the controller
  14522. */
  14523. readonly defaultModel: Nullable<AbstractMesh>;
  14524. /**
  14525. * Creates a new WebVRController from a gamepad
  14526. * @param vrGamepad the gamepad that the WebVRController should be created from
  14527. */
  14528. constructor(vrGamepad: any);
  14529. /**
  14530. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14531. */
  14532. update(): void;
  14533. /**
  14534. * Function to be called when a button is modified
  14535. */
  14536. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14537. /**
  14538. * Loads a mesh and attaches it to the controller
  14539. * @param scene the scene the mesh should be added to
  14540. * @param meshLoaded callback for when the mesh has been loaded
  14541. */
  14542. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14543. private _setButtonValue;
  14544. private _changes;
  14545. private _checkChanges;
  14546. /**
  14547. * Disposes of th webVRCOntroller
  14548. */
  14549. dispose(): void;
  14550. }
  14551. }
  14552. declare module BABYLON {
  14553. /**
  14554. * The HemisphericLight simulates the ambient environment light,
  14555. * so the passed direction is the light reflection direction, not the incoming direction.
  14556. */
  14557. export class HemisphericLight extends Light {
  14558. /**
  14559. * The groundColor is the light in the opposite direction to the one specified during creation.
  14560. * 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.
  14561. */
  14562. groundColor: Color3;
  14563. /**
  14564. * The light reflection direction, not the incoming direction.
  14565. */
  14566. direction: Vector3;
  14567. /**
  14568. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14569. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14570. * The HemisphericLight can't cast shadows.
  14571. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14572. * @param name The friendly name of the light
  14573. * @param direction The direction of the light reflection
  14574. * @param scene The scene the light belongs to
  14575. */
  14576. constructor(name: string, direction: Vector3, scene: Scene);
  14577. protected _buildUniformLayout(): void;
  14578. /**
  14579. * Returns the string "HemisphericLight".
  14580. * @return The class name
  14581. */
  14582. getClassName(): string;
  14583. /**
  14584. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14585. * Returns the updated direction.
  14586. * @param target The target the direction should point to
  14587. * @return The computed direction
  14588. */
  14589. setDirectionToTarget(target: Vector3): Vector3;
  14590. /**
  14591. * Returns the shadow generator associated to the light.
  14592. * @returns Always null for hemispheric lights because it does not support shadows.
  14593. */
  14594. getShadowGenerator(): Nullable<IShadowGenerator>;
  14595. /**
  14596. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14597. * @param effect The effect to update
  14598. * @param lightIndex The index of the light in the effect to update
  14599. * @returns The hemispheric light
  14600. */
  14601. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14602. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14603. /**
  14604. * Computes the world matrix of the node
  14605. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14606. * @param useWasUpdatedFlag defines a reserved property
  14607. * @returns the world matrix
  14608. */
  14609. computeWorldMatrix(): Matrix;
  14610. /**
  14611. * Returns the integer 3.
  14612. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14613. */
  14614. getTypeID(): number;
  14615. /**
  14616. * Prepares the list of defines specific to the light type.
  14617. * @param defines the list of defines
  14618. * @param lightIndex defines the index of the light for the effect
  14619. */
  14620. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14621. }
  14622. }
  14623. declare module BABYLON {
  14624. /** @hidden */
  14625. export var vrMultiviewToSingleviewPixelShader: {
  14626. name: string;
  14627. shader: string;
  14628. };
  14629. }
  14630. declare module BABYLON {
  14631. /**
  14632. * Renders to multiple views with a single draw call
  14633. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14634. */
  14635. export class MultiviewRenderTarget extends RenderTargetTexture {
  14636. /**
  14637. * Creates a multiview render target
  14638. * @param scene scene used with the render target
  14639. * @param size the size of the render target (used for each view)
  14640. */
  14641. constructor(scene: Scene, size?: number | {
  14642. width: number;
  14643. height: number;
  14644. } | {
  14645. ratio: number;
  14646. });
  14647. /**
  14648. * @hidden
  14649. * @param faceIndex the face index, if its a cube texture
  14650. */
  14651. _bindFrameBuffer(faceIndex?: number): void;
  14652. /**
  14653. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14654. * @returns the view count
  14655. */
  14656. getViewCount(): number;
  14657. }
  14658. }
  14659. declare module BABYLON {
  14660. /**
  14661. * Represents a camera frustum
  14662. */
  14663. export class Frustum {
  14664. /**
  14665. * Gets the planes representing the frustum
  14666. * @param transform matrix to be applied to the returned planes
  14667. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14668. */
  14669. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14670. /**
  14671. * Gets the near frustum plane transformed by the transform matrix
  14672. * @param transform transformation matrix to be applied to the resulting frustum plane
  14673. * @param frustumPlane the resuling frustum plane
  14674. */
  14675. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14676. /**
  14677. * Gets the far frustum plane transformed by the transform matrix
  14678. * @param transform transformation matrix to be applied to the resulting frustum plane
  14679. * @param frustumPlane the resuling frustum plane
  14680. */
  14681. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14682. /**
  14683. * Gets the left frustum plane transformed by the transform matrix
  14684. * @param transform transformation matrix to be applied to the resulting frustum plane
  14685. * @param frustumPlane the resuling frustum plane
  14686. */
  14687. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14688. /**
  14689. * Gets the right frustum plane transformed by the transform matrix
  14690. * @param transform transformation matrix to be applied to the resulting frustum plane
  14691. * @param frustumPlane the resuling frustum plane
  14692. */
  14693. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14694. /**
  14695. * Gets the top frustum plane transformed by the transform matrix
  14696. * @param transform transformation matrix to be applied to the resulting frustum plane
  14697. * @param frustumPlane the resuling frustum plane
  14698. */
  14699. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14700. /**
  14701. * Gets the bottom frustum plane transformed by the transform matrix
  14702. * @param transform transformation matrix to be applied to the resulting frustum plane
  14703. * @param frustumPlane the resuling frustum plane
  14704. */
  14705. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14706. /**
  14707. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14708. * @param transform transformation matrix to be applied to the resulting frustum planes
  14709. * @param frustumPlanes the resuling frustum planes
  14710. */
  14711. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14712. }
  14713. }
  14714. declare module BABYLON {
  14715. interface Engine {
  14716. /**
  14717. * Creates a new multiview render target
  14718. * @param width defines the width of the texture
  14719. * @param height defines the height of the texture
  14720. * @returns the created multiview texture
  14721. */
  14722. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14723. /**
  14724. * Binds a multiview framebuffer to be drawn to
  14725. * @param multiviewTexture texture to bind
  14726. */
  14727. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14728. }
  14729. interface Camera {
  14730. /**
  14731. * @hidden
  14732. * 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)
  14733. */
  14734. _useMultiviewToSingleView: boolean;
  14735. /**
  14736. * @hidden
  14737. * 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)
  14738. */
  14739. _multiviewTexture: Nullable<RenderTargetTexture>;
  14740. /**
  14741. * @hidden
  14742. * ensures the multiview texture of the camera exists and has the specified width/height
  14743. * @param width height to set on the multiview texture
  14744. * @param height width to set on the multiview texture
  14745. */
  14746. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14747. }
  14748. interface Scene {
  14749. /** @hidden */
  14750. _transformMatrixR: Matrix;
  14751. /** @hidden */
  14752. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14753. /** @hidden */
  14754. _createMultiviewUbo(): void;
  14755. /** @hidden */
  14756. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14757. /** @hidden */
  14758. _renderMultiviewToSingleView(camera: Camera): void;
  14759. }
  14760. }
  14761. declare module BABYLON {
  14762. /**
  14763. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14764. * This will not be used for webXR as it supports displaying texture arrays directly
  14765. */
  14766. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14767. /**
  14768. * Initializes a VRMultiviewToSingleview
  14769. * @param name name of the post process
  14770. * @param camera camera to be applied to
  14771. * @param scaleFactor scaling factor to the size of the output texture
  14772. */
  14773. constructor(name: string, camera: Camera, scaleFactor: number);
  14774. }
  14775. }
  14776. declare module BABYLON {
  14777. /**
  14778. * Interface used to define additional presentation attributes
  14779. */
  14780. export interface IVRPresentationAttributes {
  14781. /**
  14782. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14783. */
  14784. highRefreshRate: boolean;
  14785. /**
  14786. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14787. */
  14788. foveationLevel: number;
  14789. }
  14790. interface Engine {
  14791. /** @hidden */
  14792. _vrDisplay: any;
  14793. /** @hidden */
  14794. _vrSupported: boolean;
  14795. /** @hidden */
  14796. _oldSize: Size;
  14797. /** @hidden */
  14798. _oldHardwareScaleFactor: number;
  14799. /** @hidden */
  14800. _vrExclusivePointerMode: boolean;
  14801. /** @hidden */
  14802. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14803. /** @hidden */
  14804. _onVRDisplayPointerRestricted: () => void;
  14805. /** @hidden */
  14806. _onVRDisplayPointerUnrestricted: () => void;
  14807. /** @hidden */
  14808. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14809. /** @hidden */
  14810. _onVrDisplayDisconnect: Nullable<() => void>;
  14811. /** @hidden */
  14812. _onVrDisplayPresentChange: Nullable<() => void>;
  14813. /**
  14814. * Observable signaled when VR display mode changes
  14815. */
  14816. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14817. /**
  14818. * Observable signaled when VR request present is complete
  14819. */
  14820. onVRRequestPresentComplete: Observable<boolean>;
  14821. /**
  14822. * Observable signaled when VR request present starts
  14823. */
  14824. onVRRequestPresentStart: Observable<Engine>;
  14825. /**
  14826. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14827. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14828. */
  14829. isInVRExclusivePointerMode: boolean;
  14830. /**
  14831. * Gets a boolean indicating if a webVR device was detected
  14832. * @returns true if a webVR device was detected
  14833. */
  14834. isVRDevicePresent(): boolean;
  14835. /**
  14836. * Gets the current webVR device
  14837. * @returns the current webVR device (or null)
  14838. */
  14839. getVRDevice(): any;
  14840. /**
  14841. * Initializes a webVR display and starts listening to display change events
  14842. * The onVRDisplayChangedObservable will be notified upon these changes
  14843. * @returns A promise containing a VRDisplay and if vr is supported
  14844. */
  14845. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14846. /** @hidden */
  14847. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14848. /**
  14849. * Gets or sets the presentation attributes used to configure VR rendering
  14850. */
  14851. vrPresentationAttributes?: IVRPresentationAttributes;
  14852. /**
  14853. * Call this function to switch to webVR mode
  14854. * Will do nothing if webVR is not supported or if there is no webVR device
  14855. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14856. */
  14857. enableVR(): void;
  14858. /** @hidden */
  14859. _onVRFullScreenTriggered(): void;
  14860. }
  14861. }
  14862. declare module BABYLON {
  14863. /**
  14864. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14865. * IMPORTANT!! The data is right-hand data.
  14866. * @export
  14867. * @interface DevicePose
  14868. */
  14869. export interface DevicePose {
  14870. /**
  14871. * The position of the device, values in array are [x,y,z].
  14872. */
  14873. readonly position: Nullable<Float32Array>;
  14874. /**
  14875. * The linearVelocity of the device, values in array are [x,y,z].
  14876. */
  14877. readonly linearVelocity: Nullable<Float32Array>;
  14878. /**
  14879. * The linearAcceleration of the device, values in array are [x,y,z].
  14880. */
  14881. readonly linearAcceleration: Nullable<Float32Array>;
  14882. /**
  14883. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14884. */
  14885. readonly orientation: Nullable<Float32Array>;
  14886. /**
  14887. * The angularVelocity of the device, values in array are [x,y,z].
  14888. */
  14889. readonly angularVelocity: Nullable<Float32Array>;
  14890. /**
  14891. * The angularAcceleration of the device, values in array are [x,y,z].
  14892. */
  14893. readonly angularAcceleration: Nullable<Float32Array>;
  14894. }
  14895. /**
  14896. * Interface representing a pose controlled object in Babylon.
  14897. * A pose controlled object has both regular pose values as well as pose values
  14898. * from an external device such as a VR head mounted display
  14899. */
  14900. export interface PoseControlled {
  14901. /**
  14902. * The position of the object in babylon space.
  14903. */
  14904. position: Vector3;
  14905. /**
  14906. * The rotation quaternion of the object in babylon space.
  14907. */
  14908. rotationQuaternion: Quaternion;
  14909. /**
  14910. * The position of the device in babylon space.
  14911. */
  14912. devicePosition?: Vector3;
  14913. /**
  14914. * The rotation quaternion of the device in babylon space.
  14915. */
  14916. deviceRotationQuaternion: Quaternion;
  14917. /**
  14918. * The raw pose coming from the device.
  14919. */
  14920. rawPose: Nullable<DevicePose>;
  14921. /**
  14922. * The scale of the device to be used when translating from device space to babylon space.
  14923. */
  14924. deviceScaleFactor: number;
  14925. /**
  14926. * Updates the poseControlled values based on the input device pose.
  14927. * @param poseData the pose data to update the object with
  14928. */
  14929. updateFromDevice(poseData: DevicePose): void;
  14930. }
  14931. /**
  14932. * Set of options to customize the webVRCamera
  14933. */
  14934. export interface WebVROptions {
  14935. /**
  14936. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14937. */
  14938. trackPosition?: boolean;
  14939. /**
  14940. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14941. */
  14942. positionScale?: number;
  14943. /**
  14944. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14945. */
  14946. displayName?: string;
  14947. /**
  14948. * Should the native controller meshes be initialized. (default: true)
  14949. */
  14950. controllerMeshes?: boolean;
  14951. /**
  14952. * Creating a default HemiLight only on controllers. (default: true)
  14953. */
  14954. defaultLightingOnControllers?: boolean;
  14955. /**
  14956. * If you don't want to use the default VR button of the helper. (default: false)
  14957. */
  14958. useCustomVRButton?: boolean;
  14959. /**
  14960. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14961. */
  14962. customVRButton?: HTMLButtonElement;
  14963. /**
  14964. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14965. */
  14966. rayLength?: number;
  14967. /**
  14968. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14969. */
  14970. defaultHeight?: number;
  14971. /**
  14972. * If multiview should be used if availible (default: false)
  14973. */
  14974. useMultiview?: boolean;
  14975. }
  14976. /**
  14977. * This represents a WebVR camera.
  14978. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14979. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14980. */
  14981. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14982. private webVROptions;
  14983. /**
  14984. * @hidden
  14985. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14986. */
  14987. _vrDevice: any;
  14988. /**
  14989. * The rawPose of the vrDevice.
  14990. */
  14991. rawPose: Nullable<DevicePose>;
  14992. private _onVREnabled;
  14993. private _specsVersion;
  14994. private _attached;
  14995. private _frameData;
  14996. protected _descendants: Array<Node>;
  14997. private _deviceRoomPosition;
  14998. /** @hidden */
  14999. _deviceRoomRotationQuaternion: Quaternion;
  15000. private _standingMatrix;
  15001. /**
  15002. * Represents device position in babylon space.
  15003. */
  15004. devicePosition: Vector3;
  15005. /**
  15006. * Represents device rotation in babylon space.
  15007. */
  15008. deviceRotationQuaternion: Quaternion;
  15009. /**
  15010. * The scale of the device to be used when translating from device space to babylon space.
  15011. */
  15012. deviceScaleFactor: number;
  15013. private _deviceToWorld;
  15014. private _worldToDevice;
  15015. /**
  15016. * References to the webVR controllers for the vrDevice.
  15017. */
  15018. controllers: Array<WebVRController>;
  15019. /**
  15020. * Emits an event when a controller is attached.
  15021. */
  15022. onControllersAttachedObservable: Observable<WebVRController[]>;
  15023. /**
  15024. * Emits an event when a controller's mesh has been loaded;
  15025. */
  15026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15027. /**
  15028. * Emits an event when the HMD's pose has been updated.
  15029. */
  15030. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15031. private _poseSet;
  15032. /**
  15033. * If the rig cameras be used as parent instead of this camera.
  15034. */
  15035. rigParenting: boolean;
  15036. private _lightOnControllers;
  15037. private _defaultHeight?;
  15038. /**
  15039. * Instantiates a WebVRFreeCamera.
  15040. * @param name The name of the WebVRFreeCamera
  15041. * @param position The starting anchor position for the camera
  15042. * @param scene The scene the camera belongs to
  15043. * @param webVROptions a set of customizable options for the webVRCamera
  15044. */
  15045. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15046. /**
  15047. * Gets the device distance from the ground in meters.
  15048. * @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.
  15049. */
  15050. deviceDistanceToRoomGround(): number;
  15051. /**
  15052. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15053. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15054. */
  15055. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15056. /**
  15057. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15058. * @returns A promise with a boolean set to if the standing matrix is supported.
  15059. */
  15060. useStandingMatrixAsync(): Promise<boolean>;
  15061. /**
  15062. * Disposes the camera
  15063. */
  15064. dispose(): void;
  15065. /**
  15066. * Gets a vrController by name.
  15067. * @param name The name of the controller to retreive
  15068. * @returns the controller matching the name specified or null if not found
  15069. */
  15070. getControllerByName(name: string): Nullable<WebVRController>;
  15071. private _leftController;
  15072. /**
  15073. * The controller corresponding to the users left hand.
  15074. */
  15075. readonly leftController: Nullable<WebVRController>;
  15076. private _rightController;
  15077. /**
  15078. * The controller corresponding to the users right hand.
  15079. */
  15080. readonly rightController: Nullable<WebVRController>;
  15081. /**
  15082. * Casts a ray forward from the vrCamera's gaze.
  15083. * @param length Length of the ray (default: 100)
  15084. * @returns the ray corresponding to the gaze
  15085. */
  15086. getForwardRay(length?: number): Ray;
  15087. /**
  15088. * @hidden
  15089. * Updates the camera based on device's frame data
  15090. */
  15091. _checkInputs(): void;
  15092. /**
  15093. * Updates the poseControlled values based on the input device pose.
  15094. * @param poseData Pose coming from the device
  15095. */
  15096. updateFromDevice(poseData: DevicePose): void;
  15097. private _htmlElementAttached;
  15098. private _detachIfAttached;
  15099. /**
  15100. * WebVR's attach control will start broadcasting frames to the device.
  15101. * Note that in certain browsers (chrome for example) this function must be called
  15102. * within a user-interaction callback. Example:
  15103. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15104. *
  15105. * @param element html element to attach the vrDevice to
  15106. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15107. */
  15108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15109. /**
  15110. * Detaches the camera from the html element and disables VR
  15111. *
  15112. * @param element html element to detach from
  15113. */
  15114. detachControl(element: HTMLElement): void;
  15115. /**
  15116. * @returns the name of this class
  15117. */
  15118. getClassName(): string;
  15119. /**
  15120. * Calls resetPose on the vrDisplay
  15121. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15122. */
  15123. resetToCurrentRotation(): void;
  15124. /**
  15125. * @hidden
  15126. * Updates the rig cameras (left and right eye)
  15127. */
  15128. _updateRigCameras(): void;
  15129. private _workingVector;
  15130. private _oneVector;
  15131. private _workingMatrix;
  15132. private updateCacheCalled;
  15133. private _correctPositionIfNotTrackPosition;
  15134. /**
  15135. * @hidden
  15136. * Updates the cached values of the camera
  15137. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15138. */
  15139. _updateCache(ignoreParentClass?: boolean): void;
  15140. /**
  15141. * @hidden
  15142. * Get current device position in babylon world
  15143. */
  15144. _computeDevicePosition(): void;
  15145. /**
  15146. * Updates the current device position and rotation in the babylon world
  15147. */
  15148. update(): void;
  15149. /**
  15150. * @hidden
  15151. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15152. * @returns an identity matrix
  15153. */
  15154. _getViewMatrix(): Matrix;
  15155. private _tmpMatrix;
  15156. /**
  15157. * This function is called by the two RIG cameras.
  15158. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15159. * @hidden
  15160. */
  15161. _getWebVRViewMatrix(): Matrix;
  15162. /** @hidden */
  15163. _getWebVRProjectionMatrix(): Matrix;
  15164. private _onGamepadConnectedObserver;
  15165. private _onGamepadDisconnectedObserver;
  15166. private _updateCacheWhenTrackingDisabledObserver;
  15167. /**
  15168. * Initializes the controllers and their meshes
  15169. */
  15170. initControllers(): void;
  15171. }
  15172. }
  15173. declare module BABYLON {
  15174. /**
  15175. * Size options for a post process
  15176. */
  15177. export type PostProcessOptions = {
  15178. width: number;
  15179. height: number;
  15180. };
  15181. /**
  15182. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15183. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15184. */
  15185. export class PostProcess {
  15186. /** Name of the PostProcess. */
  15187. name: string;
  15188. /**
  15189. * Gets or sets the unique id of the post process
  15190. */
  15191. uniqueId: number;
  15192. /**
  15193. * Width of the texture to apply the post process on
  15194. */
  15195. width: number;
  15196. /**
  15197. * Height of the texture to apply the post process on
  15198. */
  15199. height: number;
  15200. /**
  15201. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15202. * @hidden
  15203. */
  15204. _outputTexture: Nullable<InternalTexture>;
  15205. /**
  15206. * Sampling mode used by the shader
  15207. * See https://doc.babylonjs.com/classes/3.1/texture
  15208. */
  15209. renderTargetSamplingMode: number;
  15210. /**
  15211. * Clear color to use when screen clearing
  15212. */
  15213. clearColor: Color4;
  15214. /**
  15215. * If the buffer needs to be cleared before applying the post process. (default: true)
  15216. * Should be set to false if shader will overwrite all previous pixels.
  15217. */
  15218. autoClear: boolean;
  15219. /**
  15220. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15221. */
  15222. alphaMode: number;
  15223. /**
  15224. * Sets the setAlphaBlendConstants of the babylon engine
  15225. */
  15226. alphaConstants: Color4;
  15227. /**
  15228. * Animations to be used for the post processing
  15229. */
  15230. animations: Animation[];
  15231. /**
  15232. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15233. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15234. */
  15235. enablePixelPerfectMode: boolean;
  15236. /**
  15237. * Force the postprocess to be applied without taking in account viewport
  15238. */
  15239. forceFullscreenViewport: boolean;
  15240. /**
  15241. * List of inspectable custom properties (used by the Inspector)
  15242. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15243. */
  15244. inspectableCustomProperties: IInspectable[];
  15245. /**
  15246. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15247. *
  15248. * | Value | Type | Description |
  15249. * | ----- | ----------------------------------- | ----------- |
  15250. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15251. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15252. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15253. *
  15254. */
  15255. scaleMode: number;
  15256. /**
  15257. * Force textures to be a power of two (default: false)
  15258. */
  15259. alwaysForcePOT: boolean;
  15260. private _samples;
  15261. /**
  15262. * Number of sample textures (default: 1)
  15263. */
  15264. samples: number;
  15265. /**
  15266. * Modify the scale of the post process to be the same as the viewport (default: false)
  15267. */
  15268. adaptScaleToCurrentViewport: boolean;
  15269. private _camera;
  15270. private _scene;
  15271. private _engine;
  15272. private _options;
  15273. private _reusable;
  15274. private _textureType;
  15275. /**
  15276. * Smart array of input and output textures for the post process.
  15277. * @hidden
  15278. */
  15279. _textures: SmartArray<InternalTexture>;
  15280. /**
  15281. * The index in _textures that corresponds to the output texture.
  15282. * @hidden
  15283. */
  15284. _currentRenderTextureInd: number;
  15285. private _effect;
  15286. private _samplers;
  15287. private _fragmentUrl;
  15288. private _vertexUrl;
  15289. private _parameters;
  15290. private _scaleRatio;
  15291. protected _indexParameters: any;
  15292. private _shareOutputWithPostProcess;
  15293. private _texelSize;
  15294. private _forcedOutputTexture;
  15295. /**
  15296. * Returns the fragment url or shader name used in the post process.
  15297. * @returns the fragment url or name in the shader store.
  15298. */
  15299. getEffectName(): string;
  15300. /**
  15301. * An event triggered when the postprocess is activated.
  15302. */
  15303. onActivateObservable: Observable<Camera>;
  15304. private _onActivateObserver;
  15305. /**
  15306. * A function that is added to the onActivateObservable
  15307. */
  15308. onActivate: Nullable<(camera: Camera) => void>;
  15309. /**
  15310. * An event triggered when the postprocess changes its size.
  15311. */
  15312. onSizeChangedObservable: Observable<PostProcess>;
  15313. private _onSizeChangedObserver;
  15314. /**
  15315. * A function that is added to the onSizeChangedObservable
  15316. */
  15317. onSizeChanged: (postProcess: PostProcess) => void;
  15318. /**
  15319. * An event triggered when the postprocess applies its effect.
  15320. */
  15321. onApplyObservable: Observable<Effect>;
  15322. private _onApplyObserver;
  15323. /**
  15324. * A function that is added to the onApplyObservable
  15325. */
  15326. onApply: (effect: Effect) => void;
  15327. /**
  15328. * An event triggered before rendering the postprocess
  15329. */
  15330. onBeforeRenderObservable: Observable<Effect>;
  15331. private _onBeforeRenderObserver;
  15332. /**
  15333. * A function that is added to the onBeforeRenderObservable
  15334. */
  15335. onBeforeRender: (effect: Effect) => void;
  15336. /**
  15337. * An event triggered after rendering the postprocess
  15338. */
  15339. onAfterRenderObservable: Observable<Effect>;
  15340. private _onAfterRenderObserver;
  15341. /**
  15342. * A function that is added to the onAfterRenderObservable
  15343. */
  15344. onAfterRender: (efect: Effect) => void;
  15345. /**
  15346. * 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
  15347. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15348. */
  15349. inputTexture: InternalTexture;
  15350. /**
  15351. * Gets the camera which post process is applied to.
  15352. * @returns The camera the post process is applied to.
  15353. */
  15354. getCamera(): Camera;
  15355. /**
  15356. * Gets the texel size of the postprocess.
  15357. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15358. */
  15359. readonly texelSize: Vector2;
  15360. /**
  15361. * Creates a new instance PostProcess
  15362. * @param name The name of the PostProcess.
  15363. * @param fragmentUrl The url of the fragment shader to be used.
  15364. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15365. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15366. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15367. * @param camera The camera to apply the render pass to.
  15368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15369. * @param engine The engine which the post process will be applied. (default: current engine)
  15370. * @param reusable If the post process can be reused on the same frame. (default: false)
  15371. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15372. * @param textureType Type of textures used when performing the post process. (default: 0)
  15373. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15374. * @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
  15375. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15376. */
  15377. constructor(
  15378. /** Name of the PostProcess. */
  15379. 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);
  15380. /**
  15381. * Gets a string idenfifying the name of the class
  15382. * @returns "PostProcess" string
  15383. */
  15384. getClassName(): string;
  15385. /**
  15386. * Gets the engine which this post process belongs to.
  15387. * @returns The engine the post process was enabled with.
  15388. */
  15389. getEngine(): Engine;
  15390. /**
  15391. * The effect that is created when initializing the post process.
  15392. * @returns The created effect corresponding the the postprocess.
  15393. */
  15394. getEffect(): Effect;
  15395. /**
  15396. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15397. * @param postProcess The post process to share the output with.
  15398. * @returns This post process.
  15399. */
  15400. shareOutputWith(postProcess: PostProcess): PostProcess;
  15401. /**
  15402. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15403. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15404. */
  15405. useOwnOutput(): void;
  15406. /**
  15407. * Updates the effect with the current post process compile time values and recompiles the shader.
  15408. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15409. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15410. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15411. * @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
  15412. * @param onCompiled Called when the shader has been compiled.
  15413. * @param onError Called if there is an error when compiling a shader.
  15414. */
  15415. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15416. /**
  15417. * The post process is reusable if it can be used multiple times within one frame.
  15418. * @returns If the post process is reusable
  15419. */
  15420. isReusable(): boolean;
  15421. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15422. markTextureDirty(): void;
  15423. /**
  15424. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15425. * 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.
  15426. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15427. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15428. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15429. * @returns The target texture that was bound to be written to.
  15430. */
  15431. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15432. /**
  15433. * If the post process is supported.
  15434. */
  15435. readonly isSupported: boolean;
  15436. /**
  15437. * The aspect ratio of the output texture.
  15438. */
  15439. readonly aspectRatio: number;
  15440. /**
  15441. * Get a value indicating if the post-process is ready to be used
  15442. * @returns true if the post-process is ready (shader is compiled)
  15443. */
  15444. isReady(): boolean;
  15445. /**
  15446. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15447. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15448. */
  15449. apply(): Nullable<Effect>;
  15450. private _disposeTextures;
  15451. /**
  15452. * Disposes the post process.
  15453. * @param camera The camera to dispose the post process on.
  15454. */
  15455. dispose(camera?: Camera): void;
  15456. }
  15457. }
  15458. declare module BABYLON {
  15459. /** @hidden */
  15460. export var kernelBlurVaryingDeclaration: {
  15461. name: string;
  15462. shader: string;
  15463. };
  15464. }
  15465. declare module BABYLON {
  15466. /** @hidden */
  15467. export var kernelBlurFragment: {
  15468. name: string;
  15469. shader: string;
  15470. };
  15471. }
  15472. declare module BABYLON {
  15473. /** @hidden */
  15474. export var kernelBlurFragment2: {
  15475. name: string;
  15476. shader: string;
  15477. };
  15478. }
  15479. declare module BABYLON {
  15480. /** @hidden */
  15481. export var kernelBlurPixelShader: {
  15482. name: string;
  15483. shader: string;
  15484. };
  15485. }
  15486. declare module BABYLON {
  15487. /** @hidden */
  15488. export var kernelBlurVertex: {
  15489. name: string;
  15490. shader: string;
  15491. };
  15492. }
  15493. declare module BABYLON {
  15494. /** @hidden */
  15495. export var kernelBlurVertexShader: {
  15496. name: string;
  15497. shader: string;
  15498. };
  15499. }
  15500. declare module BABYLON {
  15501. /**
  15502. * The Blur Post Process which blurs an image based on a kernel and direction.
  15503. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15504. */
  15505. export class BlurPostProcess extends PostProcess {
  15506. /** The direction in which to blur the image. */
  15507. direction: Vector2;
  15508. private blockCompilation;
  15509. protected _kernel: number;
  15510. protected _idealKernel: number;
  15511. protected _packedFloat: boolean;
  15512. private _staticDefines;
  15513. /**
  15514. * Sets the length in pixels of the blur sample region
  15515. */
  15516. /**
  15517. * Gets the length in pixels of the blur sample region
  15518. */
  15519. kernel: number;
  15520. /**
  15521. * Sets wether or not the blur needs to unpack/repack floats
  15522. */
  15523. /**
  15524. * Gets wether or not the blur is unpacking/repacking floats
  15525. */
  15526. packedFloat: boolean;
  15527. /**
  15528. * Creates a new instance BlurPostProcess
  15529. * @param name The name of the effect.
  15530. * @param direction The direction in which to blur the image.
  15531. * @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.
  15532. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15533. * @param camera The camera to apply the render pass to.
  15534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15535. * @param engine The engine which the post process will be applied. (default: current engine)
  15536. * @param reusable If the post process can be reused on the same frame. (default: false)
  15537. * @param textureType Type of textures used when performing the post process. (default: 0)
  15538. * @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)
  15539. */
  15540. constructor(name: string,
  15541. /** The direction in which to blur the image. */
  15542. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15543. /**
  15544. * Updates the effect with the current post process compile time values and recompiles the shader.
  15545. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15546. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15547. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15548. * @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
  15549. * @param onCompiled Called when the shader has been compiled.
  15550. * @param onError Called if there is an error when compiling a shader.
  15551. */
  15552. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15553. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15554. /**
  15555. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15556. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15557. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15558. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15559. * The gaps between physical kernels are compensated for in the weighting of the samples
  15560. * @param idealKernel Ideal blur kernel.
  15561. * @return Nearest best kernel.
  15562. */
  15563. protected _nearestBestKernel(idealKernel: number): number;
  15564. /**
  15565. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15566. * @param x The point on the Gaussian distribution to sample.
  15567. * @return the value of the Gaussian function at x.
  15568. */
  15569. protected _gaussianWeight(x: number): number;
  15570. /**
  15571. * Generates a string that can be used as a floating point number in GLSL.
  15572. * @param x Value to print.
  15573. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15574. * @return GLSL float string.
  15575. */
  15576. protected _glslFloat(x: number, decimalFigures?: number): string;
  15577. }
  15578. }
  15579. declare module BABYLON {
  15580. /**
  15581. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15582. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15583. * You can then easily use it as a reflectionTexture on a flat surface.
  15584. * In case the surface is not a plane, please consider relying on reflection probes.
  15585. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15586. */
  15587. export class MirrorTexture extends RenderTargetTexture {
  15588. private scene;
  15589. /**
  15590. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15591. * 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.
  15592. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15593. */
  15594. mirrorPlane: Plane;
  15595. /**
  15596. * Define the blur ratio used to blur the reflection if needed.
  15597. */
  15598. blurRatio: number;
  15599. /**
  15600. * Define the adaptive blur kernel used to blur the reflection if needed.
  15601. * This will autocompute the closest best match for the `blurKernel`
  15602. */
  15603. adaptiveBlurKernel: number;
  15604. /**
  15605. * Define the blur kernel used to blur the reflection if needed.
  15606. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15607. */
  15608. blurKernel: number;
  15609. /**
  15610. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15611. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15612. */
  15613. blurKernelX: number;
  15614. /**
  15615. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15616. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15617. */
  15618. blurKernelY: number;
  15619. private _autoComputeBlurKernel;
  15620. protected _onRatioRescale(): void;
  15621. private _updateGammaSpace;
  15622. private _imageProcessingConfigChangeObserver;
  15623. private _transformMatrix;
  15624. private _mirrorMatrix;
  15625. private _savedViewMatrix;
  15626. private _blurX;
  15627. private _blurY;
  15628. private _adaptiveBlurKernel;
  15629. private _blurKernelX;
  15630. private _blurKernelY;
  15631. private _blurRatio;
  15632. /**
  15633. * Instantiates a Mirror Texture.
  15634. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15635. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15636. * You can then easily use it as a reflectionTexture on a flat surface.
  15637. * In case the surface is not a plane, please consider relying on reflection probes.
  15638. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15639. * @param name
  15640. * @param size
  15641. * @param scene
  15642. * @param generateMipMaps
  15643. * @param type
  15644. * @param samplingMode
  15645. * @param generateDepthBuffer
  15646. */
  15647. constructor(name: string, size: number | {
  15648. width: number;
  15649. height: number;
  15650. } | {
  15651. ratio: number;
  15652. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15653. private _preparePostProcesses;
  15654. /**
  15655. * Clone the mirror texture.
  15656. * @returns the cloned texture
  15657. */
  15658. clone(): MirrorTexture;
  15659. /**
  15660. * Serialize the texture to a JSON representation you could use in Parse later on
  15661. * @returns the serialized JSON representation
  15662. */
  15663. serialize(): any;
  15664. /**
  15665. * Dispose the texture and release its associated resources.
  15666. */
  15667. dispose(): void;
  15668. }
  15669. }
  15670. declare module BABYLON {
  15671. /**
  15672. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15673. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15674. */
  15675. export class Texture extends BaseTexture {
  15676. /**
  15677. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15678. */
  15679. static SerializeBuffers: boolean;
  15680. /** @hidden */
  15681. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15682. /** @hidden */
  15683. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15684. /** @hidden */
  15685. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15686. /** nearest is mag = nearest and min = nearest and mip = linear */
  15687. static readonly NEAREST_SAMPLINGMODE: number;
  15688. /** nearest is mag = nearest and min = nearest and mip = linear */
  15689. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15690. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15691. static readonly BILINEAR_SAMPLINGMODE: number;
  15692. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15693. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15694. /** Trilinear is mag = linear and min = linear and mip = linear */
  15695. static readonly TRILINEAR_SAMPLINGMODE: number;
  15696. /** Trilinear is mag = linear and min = linear and mip = linear */
  15697. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15698. /** mag = nearest and min = nearest and mip = nearest */
  15699. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15700. /** mag = nearest and min = linear and mip = nearest */
  15701. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15702. /** mag = nearest and min = linear and mip = linear */
  15703. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15704. /** mag = nearest and min = linear and mip = none */
  15705. static readonly NEAREST_LINEAR: number;
  15706. /** mag = nearest and min = nearest and mip = none */
  15707. static readonly NEAREST_NEAREST: number;
  15708. /** mag = linear and min = nearest and mip = nearest */
  15709. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15710. /** mag = linear and min = nearest and mip = linear */
  15711. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15712. /** mag = linear and min = linear and mip = none */
  15713. static readonly LINEAR_LINEAR: number;
  15714. /** mag = linear and min = nearest and mip = none */
  15715. static readonly LINEAR_NEAREST: number;
  15716. /** Explicit coordinates mode */
  15717. static readonly EXPLICIT_MODE: number;
  15718. /** Spherical coordinates mode */
  15719. static readonly SPHERICAL_MODE: number;
  15720. /** Planar coordinates mode */
  15721. static readonly PLANAR_MODE: number;
  15722. /** Cubic coordinates mode */
  15723. static readonly CUBIC_MODE: number;
  15724. /** Projection coordinates mode */
  15725. static readonly PROJECTION_MODE: number;
  15726. /** Inverse Cubic coordinates mode */
  15727. static readonly SKYBOX_MODE: number;
  15728. /** Inverse Cubic coordinates mode */
  15729. static readonly INVCUBIC_MODE: number;
  15730. /** Equirectangular coordinates mode */
  15731. static readonly EQUIRECTANGULAR_MODE: number;
  15732. /** Equirectangular Fixed coordinates mode */
  15733. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15734. /** Equirectangular Fixed Mirrored coordinates mode */
  15735. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15736. /** Texture is not repeating outside of 0..1 UVs */
  15737. static readonly CLAMP_ADDRESSMODE: number;
  15738. /** Texture is repeating outside of 0..1 UVs */
  15739. static readonly WRAP_ADDRESSMODE: number;
  15740. /** Texture is repeating and mirrored */
  15741. static readonly MIRROR_ADDRESSMODE: number;
  15742. /**
  15743. * 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
  15744. */
  15745. static UseSerializedUrlIfAny: boolean;
  15746. /**
  15747. * Define the url of the texture.
  15748. */
  15749. url: Nullable<string>;
  15750. /**
  15751. * Define an offset on the texture to offset the u coordinates of the UVs
  15752. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15753. */
  15754. uOffset: number;
  15755. /**
  15756. * Define an offset on the texture to offset the v coordinates of the UVs
  15757. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15758. */
  15759. vOffset: number;
  15760. /**
  15761. * Define an offset on the texture to scale the u coordinates of the UVs
  15762. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15763. */
  15764. uScale: number;
  15765. /**
  15766. * Define an offset on the texture to scale the v coordinates of the UVs
  15767. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15768. */
  15769. vScale: number;
  15770. /**
  15771. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15772. * @see http://doc.babylonjs.com/how_to/more_materials
  15773. */
  15774. uAng: number;
  15775. /**
  15776. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15777. * @see http://doc.babylonjs.com/how_to/more_materials
  15778. */
  15779. vAng: number;
  15780. /**
  15781. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15782. * @see http://doc.babylonjs.com/how_to/more_materials
  15783. */
  15784. wAng: number;
  15785. /**
  15786. * Defines the center of rotation (U)
  15787. */
  15788. uRotationCenter: number;
  15789. /**
  15790. * Defines the center of rotation (V)
  15791. */
  15792. vRotationCenter: number;
  15793. /**
  15794. * Defines the center of rotation (W)
  15795. */
  15796. wRotationCenter: number;
  15797. /**
  15798. * Are mip maps generated for this texture or not.
  15799. */
  15800. readonly noMipmap: boolean;
  15801. /**
  15802. * List of inspectable custom properties (used by the Inspector)
  15803. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15804. */
  15805. inspectableCustomProperties: Nullable<IInspectable[]>;
  15806. private _noMipmap;
  15807. /** @hidden */
  15808. _invertY: boolean;
  15809. private _rowGenerationMatrix;
  15810. private _cachedTextureMatrix;
  15811. private _projectionModeMatrix;
  15812. private _t0;
  15813. private _t1;
  15814. private _t2;
  15815. private _cachedUOffset;
  15816. private _cachedVOffset;
  15817. private _cachedUScale;
  15818. private _cachedVScale;
  15819. private _cachedUAng;
  15820. private _cachedVAng;
  15821. private _cachedWAng;
  15822. private _cachedProjectionMatrixId;
  15823. private _cachedCoordinatesMode;
  15824. /** @hidden */
  15825. protected _initialSamplingMode: number;
  15826. /** @hidden */
  15827. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15828. private _deleteBuffer;
  15829. protected _format: Nullable<number>;
  15830. private _delayedOnLoad;
  15831. private _delayedOnError;
  15832. private _mimeType?;
  15833. /**
  15834. * Observable triggered once the texture has been loaded.
  15835. */
  15836. onLoadObservable: Observable<Texture>;
  15837. protected _isBlocking: boolean;
  15838. /**
  15839. * Is the texture preventing material to render while loading.
  15840. * If false, a default texture will be used instead of the loading one during the preparation step.
  15841. */
  15842. isBlocking: boolean;
  15843. /**
  15844. * Get the current sampling mode associated with the texture.
  15845. */
  15846. readonly samplingMode: number;
  15847. /**
  15848. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15849. */
  15850. readonly invertY: boolean;
  15851. /**
  15852. * Instantiates a new texture.
  15853. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15854. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15855. * @param url defines the url of the picture to load as a texture
  15856. * @param scene defines the scene or engine the texture will belong to
  15857. * @param noMipmap defines if the texture will require mip maps or not
  15858. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15859. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15860. * @param onLoad defines a callback triggered when the texture has been loaded
  15861. * @param onError defines a callback triggered when an error occurred during the loading session
  15862. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15863. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15864. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15865. * @param mimeType defines an optional mime type information
  15866. */
  15867. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15868. /**
  15869. * Update the url (and optional buffer) of this texture if url was null during construction.
  15870. * @param url the url of the texture
  15871. * @param buffer the buffer of the texture (defaults to null)
  15872. * @param onLoad callback called when the texture is loaded (defaults to null)
  15873. */
  15874. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15875. /**
  15876. * Finish the loading sequence of a texture flagged as delayed load.
  15877. * @hidden
  15878. */
  15879. delayLoad(): void;
  15880. private _prepareRowForTextureGeneration;
  15881. /**
  15882. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15883. * @returns the transform matrix of the texture.
  15884. */
  15885. getTextureMatrix(): Matrix;
  15886. /**
  15887. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15888. * @returns The reflection texture transform
  15889. */
  15890. getReflectionTextureMatrix(): Matrix;
  15891. /**
  15892. * Clones the texture.
  15893. * @returns the cloned texture
  15894. */
  15895. clone(): Texture;
  15896. /**
  15897. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15898. * @returns The JSON representation of the texture
  15899. */
  15900. serialize(): any;
  15901. /**
  15902. * Get the current class name of the texture useful for serialization or dynamic coding.
  15903. * @returns "Texture"
  15904. */
  15905. getClassName(): string;
  15906. /**
  15907. * Dispose the texture and release its associated resources.
  15908. */
  15909. dispose(): void;
  15910. /**
  15911. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15912. * @param parsedTexture Define the JSON representation of the texture
  15913. * @param scene Define the scene the parsed texture should be instantiated in
  15914. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15915. * @returns The parsed texture if successful
  15916. */
  15917. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15918. /**
  15919. * Creates a texture from its base 64 representation.
  15920. * @param data Define the base64 payload without the data: prefix
  15921. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15922. * @param scene Define the scene the texture should belong to
  15923. * @param noMipmap Forces the texture to not create mip map information if true
  15924. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15925. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15926. * @param onLoad define a callback triggered when the texture has been loaded
  15927. * @param onError define a callback triggered when an error occurred during the loading session
  15928. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15929. * @returns the created texture
  15930. */
  15931. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15932. /**
  15933. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15934. * @param data Define the base64 payload without the data: prefix
  15935. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15936. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15937. * @param scene Define the scene the texture should belong to
  15938. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15939. * @param noMipmap Forces the texture to not create mip map information if true
  15940. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15941. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15942. * @param onLoad define a callback triggered when the texture has been loaded
  15943. * @param onError define a callback triggered when an error occurred during the loading session
  15944. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15945. * @returns the created texture
  15946. */
  15947. 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;
  15948. }
  15949. }
  15950. declare module BABYLON {
  15951. /**
  15952. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15953. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15954. */
  15955. export class PostProcessManager {
  15956. private _scene;
  15957. private _indexBuffer;
  15958. private _vertexBuffers;
  15959. /**
  15960. * Creates a new instance PostProcess
  15961. * @param scene The scene that the post process is associated with.
  15962. */
  15963. constructor(scene: Scene);
  15964. private _prepareBuffers;
  15965. private _buildIndexBuffer;
  15966. /**
  15967. * Rebuilds the vertex buffers of the manager.
  15968. * @hidden
  15969. */
  15970. _rebuild(): void;
  15971. /**
  15972. * Prepares a frame to be run through a post process.
  15973. * @param sourceTexture The input texture to the post procesess. (default: null)
  15974. * @param postProcesses An array of post processes to be run. (default: null)
  15975. * @returns True if the post processes were able to be run.
  15976. * @hidden
  15977. */
  15978. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15979. /**
  15980. * Manually render a set of post processes to a texture.
  15981. * @param postProcesses An array of post processes to be run.
  15982. * @param targetTexture The target texture to render to.
  15983. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15984. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15985. * @param lodLevel defines which lod of the texture to render to
  15986. */
  15987. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15988. /**
  15989. * Finalize the result of the output of the postprocesses.
  15990. * @param doNotPresent If true the result will not be displayed to the screen.
  15991. * @param targetTexture The target texture to render to.
  15992. * @param faceIndex The index of the face to bind the target texture to.
  15993. * @param postProcesses The array of post processes to render.
  15994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15995. * @hidden
  15996. */
  15997. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15998. /**
  15999. * Disposes of the post process manager.
  16000. */
  16001. dispose(): void;
  16002. }
  16003. }
  16004. declare module BABYLON {
  16005. /** Interface used by value gradients (color, factor, ...) */
  16006. export interface IValueGradient {
  16007. /**
  16008. * Gets or sets the gradient value (between 0 and 1)
  16009. */
  16010. gradient: number;
  16011. }
  16012. /** Class used to store color4 gradient */
  16013. export class ColorGradient implements IValueGradient {
  16014. /**
  16015. * Gets or sets the gradient value (between 0 and 1)
  16016. */
  16017. gradient: number;
  16018. /**
  16019. * Gets or sets first associated color
  16020. */
  16021. color1: Color4;
  16022. /**
  16023. * Gets or sets second associated color
  16024. */
  16025. color2?: Color4;
  16026. /**
  16027. * Will get a color picked randomly between color1 and color2.
  16028. * If color2 is undefined then color1 will be used
  16029. * @param result defines the target Color4 to store the result in
  16030. */
  16031. getColorToRef(result: Color4): void;
  16032. }
  16033. /** Class used to store color 3 gradient */
  16034. export class Color3Gradient implements IValueGradient {
  16035. /**
  16036. * Gets or sets the gradient value (between 0 and 1)
  16037. */
  16038. gradient: number;
  16039. /**
  16040. * Gets or sets the associated color
  16041. */
  16042. color: Color3;
  16043. }
  16044. /** Class used to store factor gradient */
  16045. export class FactorGradient implements IValueGradient {
  16046. /**
  16047. * Gets or sets the gradient value (between 0 and 1)
  16048. */
  16049. gradient: number;
  16050. /**
  16051. * Gets or sets first associated factor
  16052. */
  16053. factor1: number;
  16054. /**
  16055. * Gets or sets second associated factor
  16056. */
  16057. factor2?: number;
  16058. /**
  16059. * Will get a number picked randomly between factor1 and factor2.
  16060. * If factor2 is undefined then factor1 will be used
  16061. * @returns the picked number
  16062. */
  16063. getFactor(): number;
  16064. }
  16065. /**
  16066. * Helper used to simplify some generic gradient tasks
  16067. */
  16068. export class GradientHelper {
  16069. /**
  16070. * Gets the current gradient from an array of IValueGradient
  16071. * @param ratio defines the current ratio to get
  16072. * @param gradients defines the array of IValueGradient
  16073. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16074. */
  16075. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16076. }
  16077. }
  16078. declare module BABYLON {
  16079. interface ThinEngine {
  16080. /**
  16081. * Creates a dynamic texture
  16082. * @param width defines the width of the texture
  16083. * @param height defines the height of the texture
  16084. * @param generateMipMaps defines if the engine should generate the mip levels
  16085. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16086. * @returns the dynamic texture inside an InternalTexture
  16087. */
  16088. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16089. /**
  16090. * Update the content of a dynamic texture
  16091. * @param texture defines the texture to update
  16092. * @param canvas defines the canvas containing the source
  16093. * @param invertY defines if data must be stored with Y axis inverted
  16094. * @param premulAlpha defines if alpha is stored as premultiplied
  16095. * @param format defines the format of the data
  16096. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16097. */
  16098. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16099. }
  16100. }
  16101. declare module BABYLON {
  16102. /**
  16103. * Helper class used to generate a canvas to manipulate images
  16104. */
  16105. export class CanvasGenerator {
  16106. /**
  16107. * Create a new canvas (or offscreen canvas depending on the context)
  16108. * @param width defines the expected width
  16109. * @param height defines the expected height
  16110. * @return a new canvas or offscreen canvas
  16111. */
  16112. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * A class extending Texture allowing drawing on a texture
  16118. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16119. */
  16120. export class DynamicTexture extends Texture {
  16121. private _generateMipMaps;
  16122. private _canvas;
  16123. private _context;
  16124. private _engine;
  16125. /**
  16126. * Creates a DynamicTexture
  16127. * @param name defines the name of the texture
  16128. * @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
  16129. * @param scene defines the scene where you want the texture
  16130. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16131. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16132. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16133. */
  16134. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16135. /**
  16136. * Get the current class name of the texture useful for serialization or dynamic coding.
  16137. * @returns "DynamicTexture"
  16138. */
  16139. getClassName(): string;
  16140. /**
  16141. * Gets the current state of canRescale
  16142. */
  16143. readonly canRescale: boolean;
  16144. private _recreate;
  16145. /**
  16146. * Scales the texture
  16147. * @param ratio the scale factor to apply to both width and height
  16148. */
  16149. scale(ratio: number): void;
  16150. /**
  16151. * Resizes the texture
  16152. * @param width the new width
  16153. * @param height the new height
  16154. */
  16155. scaleTo(width: number, height: number): void;
  16156. /**
  16157. * Gets the context of the canvas used by the texture
  16158. * @returns the canvas context of the dynamic texture
  16159. */
  16160. getContext(): CanvasRenderingContext2D;
  16161. /**
  16162. * Clears the texture
  16163. */
  16164. clear(): void;
  16165. /**
  16166. * Updates the texture
  16167. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16168. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16169. */
  16170. update(invertY?: boolean, premulAlpha?: boolean): void;
  16171. /**
  16172. * Draws text onto the texture
  16173. * @param text defines the text to be drawn
  16174. * @param x defines the placement of the text from the left
  16175. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16176. * @param font defines the font to be used with font-style, font-size, font-name
  16177. * @param color defines the color used for the text
  16178. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16179. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16180. * @param update defines whether texture is immediately update (default is true)
  16181. */
  16182. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16183. /**
  16184. * Clones the texture
  16185. * @returns the clone of the texture.
  16186. */
  16187. clone(): DynamicTexture;
  16188. /**
  16189. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16190. * @returns a serialized dynamic texture object
  16191. */
  16192. serialize(): any;
  16193. /** @hidden */
  16194. _rebuild(): void;
  16195. }
  16196. }
  16197. declare module BABYLON {
  16198. interface AbstractScene {
  16199. /**
  16200. * The list of procedural textures added to the scene
  16201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16202. */
  16203. proceduralTextures: Array<ProceduralTexture>;
  16204. }
  16205. /**
  16206. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16207. * in a given scene.
  16208. */
  16209. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16210. /**
  16211. * The component name helpfull to identify the component in the list of scene components.
  16212. */
  16213. readonly name: string;
  16214. /**
  16215. * The scene the component belongs to.
  16216. */
  16217. scene: Scene;
  16218. /**
  16219. * Creates a new instance of the component for the given scene
  16220. * @param scene Defines the scene to register the component in
  16221. */
  16222. constructor(scene: Scene);
  16223. /**
  16224. * Registers the component in a given scene
  16225. */
  16226. register(): void;
  16227. /**
  16228. * Rebuilds the elements related to this component in case of
  16229. * context lost for instance.
  16230. */
  16231. rebuild(): void;
  16232. /**
  16233. * Disposes the component and the associated ressources.
  16234. */
  16235. dispose(): void;
  16236. private _beforeClear;
  16237. }
  16238. }
  16239. declare module BABYLON {
  16240. interface ThinEngine {
  16241. /**
  16242. * Creates a new render target cube texture
  16243. * @param size defines the size of the texture
  16244. * @param options defines the options used to create the texture
  16245. * @returns a new render target cube texture stored in an InternalTexture
  16246. */
  16247. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16248. }
  16249. }
  16250. declare module BABYLON {
  16251. /** @hidden */
  16252. export var proceduralVertexShader: {
  16253. name: string;
  16254. shader: string;
  16255. };
  16256. }
  16257. declare module BABYLON {
  16258. /**
  16259. * 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.
  16260. * This is the base class of any Procedural texture and contains most of the shareable code.
  16261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16262. */
  16263. export class ProceduralTexture extends Texture {
  16264. isCube: boolean;
  16265. /**
  16266. * Define if the texture is enabled or not (disabled texture will not render)
  16267. */
  16268. isEnabled: boolean;
  16269. /**
  16270. * Define if the texture must be cleared before rendering (default is true)
  16271. */
  16272. autoClear: boolean;
  16273. /**
  16274. * Callback called when the texture is generated
  16275. */
  16276. onGenerated: () => void;
  16277. /**
  16278. * Event raised when the texture is generated
  16279. */
  16280. onGeneratedObservable: Observable<ProceduralTexture>;
  16281. /** @hidden */
  16282. _generateMipMaps: boolean;
  16283. /** @hidden **/
  16284. _effect: Effect;
  16285. /** @hidden */
  16286. _textures: {
  16287. [key: string]: Texture;
  16288. };
  16289. private _size;
  16290. private _currentRefreshId;
  16291. private _refreshRate;
  16292. private _vertexBuffers;
  16293. private _indexBuffer;
  16294. private _uniforms;
  16295. private _samplers;
  16296. private _fragment;
  16297. private _floats;
  16298. private _ints;
  16299. private _floatsArrays;
  16300. private _colors3;
  16301. private _colors4;
  16302. private _vectors2;
  16303. private _vectors3;
  16304. private _matrices;
  16305. private _fallbackTexture;
  16306. private _fallbackTextureUsed;
  16307. private _engine;
  16308. private _cachedDefines;
  16309. private _contentUpdateId;
  16310. private _contentData;
  16311. /**
  16312. * Instantiates a new procedural texture.
  16313. * 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.
  16314. * This is the base class of any Procedural texture and contains most of the shareable code.
  16315. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16316. * @param name Define the name of the texture
  16317. * @param size Define the size of the texture to create
  16318. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16319. * @param scene Define the scene the texture belongs to
  16320. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16321. * @param generateMipMaps Define if the texture should creates mip maps or not
  16322. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16323. */
  16324. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16325. /**
  16326. * The effect that is created when initializing the post process.
  16327. * @returns The created effect corresponding the the postprocess.
  16328. */
  16329. getEffect(): Effect;
  16330. /**
  16331. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16332. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16333. */
  16334. getContent(): Nullable<ArrayBufferView>;
  16335. private _createIndexBuffer;
  16336. /** @hidden */
  16337. _rebuild(): void;
  16338. /**
  16339. * Resets the texture in order to recreate its associated resources.
  16340. * This can be called in case of context loss
  16341. */
  16342. reset(): void;
  16343. protected _getDefines(): string;
  16344. /**
  16345. * Is the texture ready to be used ? (rendered at least once)
  16346. * @returns true if ready, otherwise, false.
  16347. */
  16348. isReady(): boolean;
  16349. /**
  16350. * Resets the refresh counter of the texture and start bak from scratch.
  16351. * Could be useful to regenerate the texture if it is setup to render only once.
  16352. */
  16353. resetRefreshCounter(): void;
  16354. /**
  16355. * Set the fragment shader to use in order to render the texture.
  16356. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16357. */
  16358. setFragment(fragment: any): void;
  16359. /**
  16360. * Define the refresh rate of the texture or the rendering frequency.
  16361. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16362. */
  16363. refreshRate: number;
  16364. /** @hidden */
  16365. _shouldRender(): boolean;
  16366. /**
  16367. * Get the size the texture is rendering at.
  16368. * @returns the size (texture is always squared)
  16369. */
  16370. getRenderSize(): number;
  16371. /**
  16372. * Resize the texture to new value.
  16373. * @param size Define the new size the texture should have
  16374. * @param generateMipMaps Define whether the new texture should create mip maps
  16375. */
  16376. resize(size: number, generateMipMaps: boolean): void;
  16377. private _checkUniform;
  16378. /**
  16379. * Set a texture in the shader program used to render.
  16380. * @param name Define the name of the uniform samplers as defined in the shader
  16381. * @param texture Define the texture to bind to this sampler
  16382. * @return the texture itself allowing "fluent" like uniform updates
  16383. */
  16384. setTexture(name: string, texture: Texture): ProceduralTexture;
  16385. /**
  16386. * Set a float in the shader.
  16387. * @param name Define the name of the uniform as defined in the shader
  16388. * @param value Define the value to give to the uniform
  16389. * @return the texture itself allowing "fluent" like uniform updates
  16390. */
  16391. setFloat(name: string, value: number): ProceduralTexture;
  16392. /**
  16393. * Set a int in the shader.
  16394. * @param name Define the name of the uniform as defined in the shader
  16395. * @param value Define the value to give to the uniform
  16396. * @return the texture itself allowing "fluent" like uniform updates
  16397. */
  16398. setInt(name: string, value: number): ProceduralTexture;
  16399. /**
  16400. * Set an array of floats in the shader.
  16401. * @param name Define the name of the uniform as defined in the shader
  16402. * @param value Define the value to give to the uniform
  16403. * @return the texture itself allowing "fluent" like uniform updates
  16404. */
  16405. setFloats(name: string, value: number[]): ProceduralTexture;
  16406. /**
  16407. * Set a vec3 in the shader from a Color3.
  16408. * @param name Define the name of the uniform as defined in the shader
  16409. * @param value Define the value to give to the uniform
  16410. * @return the texture itself allowing "fluent" like uniform updates
  16411. */
  16412. setColor3(name: string, value: Color3): ProceduralTexture;
  16413. /**
  16414. * Set a vec4 in the shader from a Color4.
  16415. * @param name Define the name of the uniform as defined in the shader
  16416. * @param value Define the value to give to the uniform
  16417. * @return the texture itself allowing "fluent" like uniform updates
  16418. */
  16419. setColor4(name: string, value: Color4): ProceduralTexture;
  16420. /**
  16421. * Set a vec2 in the shader from a Vector2.
  16422. * @param name Define the name of the uniform as defined in the shader
  16423. * @param value Define the value to give to the uniform
  16424. * @return the texture itself allowing "fluent" like uniform updates
  16425. */
  16426. setVector2(name: string, value: Vector2): ProceduralTexture;
  16427. /**
  16428. * Set a vec3 in the shader from a Vector3.
  16429. * @param name Define the name of the uniform as defined in the shader
  16430. * @param value Define the value to give to the uniform
  16431. * @return the texture itself allowing "fluent" like uniform updates
  16432. */
  16433. setVector3(name: string, value: Vector3): ProceduralTexture;
  16434. /**
  16435. * Set a mat4 in the shader from a MAtrix.
  16436. * @param name Define the name of the uniform as defined in the shader
  16437. * @param value Define the value to give to the uniform
  16438. * @return the texture itself allowing "fluent" like uniform updates
  16439. */
  16440. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16441. /**
  16442. * Render the texture to its associated render target.
  16443. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16444. */
  16445. render(useCameraPostProcess?: boolean): void;
  16446. /**
  16447. * Clone the texture.
  16448. * @returns the cloned texture
  16449. */
  16450. clone(): ProceduralTexture;
  16451. /**
  16452. * Dispose the texture and release its asoociated resources.
  16453. */
  16454. dispose(): void;
  16455. }
  16456. }
  16457. declare module BABYLON {
  16458. /**
  16459. * This represents the base class for particle system in Babylon.
  16460. * 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.
  16461. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16462. * @example https://doc.babylonjs.com/babylon101/particles
  16463. */
  16464. export class BaseParticleSystem {
  16465. /**
  16466. * Source color is added to the destination color without alpha affecting the result
  16467. */
  16468. static BLENDMODE_ONEONE: number;
  16469. /**
  16470. * Blend current color and particle color using particle’s alpha
  16471. */
  16472. static BLENDMODE_STANDARD: number;
  16473. /**
  16474. * Add current color and particle color multiplied by particle’s alpha
  16475. */
  16476. static BLENDMODE_ADD: number;
  16477. /**
  16478. * Multiply current color with particle color
  16479. */
  16480. static BLENDMODE_MULTIPLY: number;
  16481. /**
  16482. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16483. */
  16484. static BLENDMODE_MULTIPLYADD: number;
  16485. /**
  16486. * List of animations used by the particle system.
  16487. */
  16488. animations: Animation[];
  16489. /**
  16490. * The id of the Particle system.
  16491. */
  16492. id: string;
  16493. /**
  16494. * The friendly name of the Particle system.
  16495. */
  16496. name: string;
  16497. /**
  16498. * The rendering group used by the Particle system to chose when to render.
  16499. */
  16500. renderingGroupId: number;
  16501. /**
  16502. * The emitter represents the Mesh or position we are attaching the particle system to.
  16503. */
  16504. emitter: Nullable<AbstractMesh | Vector3>;
  16505. /**
  16506. * The maximum number of particles to emit per frame
  16507. */
  16508. emitRate: number;
  16509. /**
  16510. * If you want to launch only a few particles at once, that can be done, as well.
  16511. */
  16512. manualEmitCount: number;
  16513. /**
  16514. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16515. */
  16516. updateSpeed: number;
  16517. /**
  16518. * The amount of time the particle system is running (depends of the overall update speed).
  16519. */
  16520. targetStopDuration: number;
  16521. /**
  16522. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16523. */
  16524. disposeOnStop: boolean;
  16525. /**
  16526. * Minimum power of emitting particles.
  16527. */
  16528. minEmitPower: number;
  16529. /**
  16530. * Maximum power of emitting particles.
  16531. */
  16532. maxEmitPower: number;
  16533. /**
  16534. * Minimum life time of emitting particles.
  16535. */
  16536. minLifeTime: number;
  16537. /**
  16538. * Maximum life time of emitting particles.
  16539. */
  16540. maxLifeTime: number;
  16541. /**
  16542. * Minimum Size of emitting particles.
  16543. */
  16544. minSize: number;
  16545. /**
  16546. * Maximum Size of emitting particles.
  16547. */
  16548. maxSize: number;
  16549. /**
  16550. * Minimum scale of emitting particles on X axis.
  16551. */
  16552. minScaleX: number;
  16553. /**
  16554. * Maximum scale of emitting particles on X axis.
  16555. */
  16556. maxScaleX: number;
  16557. /**
  16558. * Minimum scale of emitting particles on Y axis.
  16559. */
  16560. minScaleY: number;
  16561. /**
  16562. * Maximum scale of emitting particles on Y axis.
  16563. */
  16564. maxScaleY: number;
  16565. /**
  16566. * Gets or sets the minimal initial rotation in radians.
  16567. */
  16568. minInitialRotation: number;
  16569. /**
  16570. * Gets or sets the maximal initial rotation in radians.
  16571. */
  16572. maxInitialRotation: number;
  16573. /**
  16574. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16575. */
  16576. minAngularSpeed: number;
  16577. /**
  16578. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16579. */
  16580. maxAngularSpeed: number;
  16581. /**
  16582. * The texture used to render each particle. (this can be a spritesheet)
  16583. */
  16584. particleTexture: Nullable<Texture>;
  16585. /**
  16586. * The layer mask we are rendering the particles through.
  16587. */
  16588. layerMask: number;
  16589. /**
  16590. * This can help using your own shader to render the particle system.
  16591. * The according effect will be created
  16592. */
  16593. customShader: any;
  16594. /**
  16595. * By default particle system starts as soon as they are created. This prevents the
  16596. * automatic start to happen and let you decide when to start emitting particles.
  16597. */
  16598. preventAutoStart: boolean;
  16599. private _noiseTexture;
  16600. /**
  16601. * Gets or sets a texture used to add random noise to particle positions
  16602. */
  16603. noiseTexture: Nullable<ProceduralTexture>;
  16604. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16605. noiseStrength: Vector3;
  16606. /**
  16607. * Callback triggered when the particle animation is ending.
  16608. */
  16609. onAnimationEnd: Nullable<() => void>;
  16610. /**
  16611. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16612. */
  16613. blendMode: number;
  16614. /**
  16615. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16616. * to override the particles.
  16617. */
  16618. forceDepthWrite: boolean;
  16619. /** 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 */
  16620. preWarmCycles: number;
  16621. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16622. preWarmStepOffset: number;
  16623. /**
  16624. * 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)
  16625. */
  16626. spriteCellChangeSpeed: number;
  16627. /**
  16628. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16629. */
  16630. startSpriteCellID: number;
  16631. /**
  16632. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16633. */
  16634. endSpriteCellID: number;
  16635. /**
  16636. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16637. */
  16638. spriteCellWidth: number;
  16639. /**
  16640. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16641. */
  16642. spriteCellHeight: number;
  16643. /**
  16644. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16645. */
  16646. spriteRandomStartCell: boolean;
  16647. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16648. translationPivot: Vector2;
  16649. /** @hidden */
  16650. protected _isAnimationSheetEnabled: boolean;
  16651. /**
  16652. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16653. */
  16654. beginAnimationOnStart: boolean;
  16655. /**
  16656. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16657. */
  16658. beginAnimationFrom: number;
  16659. /**
  16660. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16661. */
  16662. beginAnimationTo: number;
  16663. /**
  16664. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16665. */
  16666. beginAnimationLoop: boolean;
  16667. /**
  16668. * Gets or sets a world offset applied to all particles
  16669. */
  16670. worldOffset: Vector3;
  16671. /**
  16672. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16673. */
  16674. isAnimationSheetEnabled: boolean;
  16675. /**
  16676. * Get hosting scene
  16677. * @returns the scene
  16678. */
  16679. getScene(): Scene;
  16680. /**
  16681. * You can use gravity if you want to give an orientation to your particles.
  16682. */
  16683. gravity: Vector3;
  16684. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16685. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16686. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16687. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16688. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16689. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16690. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16691. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16692. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16693. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16694. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16695. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16696. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16697. /**
  16698. * Defines the delay in milliseconds before starting the system (0 by default)
  16699. */
  16700. startDelay: number;
  16701. /**
  16702. * Gets the current list of drag gradients.
  16703. * You must use addDragGradient and removeDragGradient to udpate this list
  16704. * @returns the list of drag gradients
  16705. */
  16706. getDragGradients(): Nullable<Array<FactorGradient>>;
  16707. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16708. limitVelocityDamping: number;
  16709. /**
  16710. * Gets the current list of limit velocity gradients.
  16711. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16712. * @returns the list of limit velocity gradients
  16713. */
  16714. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16715. /**
  16716. * Gets the current list of color gradients.
  16717. * You must use addColorGradient and removeColorGradient to udpate this list
  16718. * @returns the list of color gradients
  16719. */
  16720. getColorGradients(): Nullable<Array<ColorGradient>>;
  16721. /**
  16722. * Gets the current list of size gradients.
  16723. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16724. * @returns the list of size gradients
  16725. */
  16726. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16727. /**
  16728. * Gets the current list of color remap gradients.
  16729. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16730. * @returns the list of color remap gradients
  16731. */
  16732. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16733. /**
  16734. * Gets the current list of alpha remap gradients.
  16735. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16736. * @returns the list of alpha remap gradients
  16737. */
  16738. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16739. /**
  16740. * Gets the current list of life time gradients.
  16741. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16742. * @returns the list of life time gradients
  16743. */
  16744. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16745. /**
  16746. * Gets the current list of angular speed gradients.
  16747. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16748. * @returns the list of angular speed gradients
  16749. */
  16750. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16751. /**
  16752. * Gets the current list of velocity gradients.
  16753. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16754. * @returns the list of velocity gradients
  16755. */
  16756. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16757. /**
  16758. * Gets the current list of start size gradients.
  16759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16760. * @returns the list of start size gradients
  16761. */
  16762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16763. /**
  16764. * Gets the current list of emit rate gradients.
  16765. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16766. * @returns the list of emit rate gradients
  16767. */
  16768. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16769. /**
  16770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16771. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16772. */
  16773. direction1: Vector3;
  16774. /**
  16775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16776. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16777. */
  16778. direction2: Vector3;
  16779. /**
  16780. * 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.
  16781. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16782. */
  16783. minEmitBox: Vector3;
  16784. /**
  16785. * 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.
  16786. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16787. */
  16788. maxEmitBox: Vector3;
  16789. /**
  16790. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16791. */
  16792. color1: Color4;
  16793. /**
  16794. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16795. */
  16796. color2: Color4;
  16797. /**
  16798. * Color the particle will have at the end of its lifetime
  16799. */
  16800. colorDead: Color4;
  16801. /**
  16802. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16803. */
  16804. textureMask: Color4;
  16805. /**
  16806. * The particle emitter type defines the emitter used by the particle system.
  16807. * It can be for example box, sphere, or cone...
  16808. */
  16809. particleEmitterType: IParticleEmitterType;
  16810. /** @hidden */
  16811. _isSubEmitter: boolean;
  16812. /**
  16813. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16814. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16815. */
  16816. billboardMode: number;
  16817. protected _isBillboardBased: boolean;
  16818. /**
  16819. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16820. */
  16821. isBillboardBased: boolean;
  16822. /**
  16823. * The scene the particle system belongs to.
  16824. */
  16825. protected _scene: Scene;
  16826. /**
  16827. * Local cache of defines for image processing.
  16828. */
  16829. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16830. /**
  16831. * Default configuration related to image processing available in the standard Material.
  16832. */
  16833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16834. /**
  16835. * Gets the image processing configuration used either in this material.
  16836. */
  16837. /**
  16838. * Sets the Default image processing configuration used either in the this material.
  16839. *
  16840. * If sets to null, the scene one is in use.
  16841. */
  16842. imageProcessingConfiguration: ImageProcessingConfiguration;
  16843. /**
  16844. * Attaches a new image processing configuration to the Standard Material.
  16845. * @param configuration
  16846. */
  16847. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16848. /** @hidden */
  16849. protected _reset(): void;
  16850. /** @hidden */
  16851. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16852. /**
  16853. * Instantiates a particle system.
  16854. * 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.
  16855. * @param name The name of the particle system
  16856. */
  16857. constructor(name: string);
  16858. /**
  16859. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16862. * @returns the emitter
  16863. */
  16864. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16865. /**
  16866. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16867. * @param radius The radius of the hemisphere to emit from
  16868. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16869. * @returns the emitter
  16870. */
  16871. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16872. /**
  16873. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16874. * @param radius The radius of the sphere to emit from
  16875. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16876. * @returns the emitter
  16877. */
  16878. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16879. /**
  16880. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16881. * @param radius The radius of the sphere to emit from
  16882. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16883. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16884. * @returns the emitter
  16885. */
  16886. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16887. /**
  16888. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16889. * @param radius The radius of the emission cylinder
  16890. * @param height The height of the emission cylinder
  16891. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16892. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16893. * @returns the emitter
  16894. */
  16895. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16896. /**
  16897. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16898. * @param radius The radius of the cylinder to emit from
  16899. * @param height The height of the emission cylinder
  16900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16903. * @returns the emitter
  16904. */
  16905. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16906. /**
  16907. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16908. * @param radius The radius of the cone to emit from
  16909. * @param angle The base angle of the cone
  16910. * @returns the emitter
  16911. */
  16912. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16913. /**
  16914. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16917. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16918. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16919. * @returns the emitter
  16920. */
  16921. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16922. }
  16923. }
  16924. declare module BABYLON {
  16925. /**
  16926. * Type of sub emitter
  16927. */
  16928. export enum SubEmitterType {
  16929. /**
  16930. * Attached to the particle over it's lifetime
  16931. */
  16932. ATTACHED = 0,
  16933. /**
  16934. * Created when the particle dies
  16935. */
  16936. END = 1
  16937. }
  16938. /**
  16939. * Sub emitter class used to emit particles from an existing particle
  16940. */
  16941. export class SubEmitter {
  16942. /**
  16943. * the particle system to be used by the sub emitter
  16944. */
  16945. particleSystem: ParticleSystem;
  16946. /**
  16947. * Type of the submitter (Default: END)
  16948. */
  16949. type: SubEmitterType;
  16950. /**
  16951. * 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)
  16952. * Note: This only is supported when using an emitter of type Mesh
  16953. */
  16954. inheritDirection: boolean;
  16955. /**
  16956. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16957. */
  16958. inheritedVelocityAmount: number;
  16959. /**
  16960. * Creates a sub emitter
  16961. * @param particleSystem the particle system to be used by the sub emitter
  16962. */
  16963. constructor(
  16964. /**
  16965. * the particle system to be used by the sub emitter
  16966. */
  16967. particleSystem: ParticleSystem);
  16968. /**
  16969. * Clones the sub emitter
  16970. * @returns the cloned sub emitter
  16971. */
  16972. clone(): SubEmitter;
  16973. /**
  16974. * Serialize current object to a JSON object
  16975. * @returns the serialized object
  16976. */
  16977. serialize(): any;
  16978. /** @hidden */
  16979. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16980. /**
  16981. * Creates a new SubEmitter from a serialized JSON version
  16982. * @param serializationObject defines the JSON object to read from
  16983. * @param scene defines the hosting scene
  16984. * @param rootUrl defines the rootUrl for data loading
  16985. * @returns a new SubEmitter
  16986. */
  16987. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16988. /** Release associated resources */
  16989. dispose(): void;
  16990. }
  16991. }
  16992. declare module BABYLON {
  16993. /** @hidden */
  16994. export var clipPlaneFragmentDeclaration: {
  16995. name: string;
  16996. shader: string;
  16997. };
  16998. }
  16999. declare module BABYLON {
  17000. /** @hidden */
  17001. export var imageProcessingDeclaration: {
  17002. name: string;
  17003. shader: string;
  17004. };
  17005. }
  17006. declare module BABYLON {
  17007. /** @hidden */
  17008. export var imageProcessingFunctions: {
  17009. name: string;
  17010. shader: string;
  17011. };
  17012. }
  17013. declare module BABYLON {
  17014. /** @hidden */
  17015. export var clipPlaneFragment: {
  17016. name: string;
  17017. shader: string;
  17018. };
  17019. }
  17020. declare module BABYLON {
  17021. /** @hidden */
  17022. export var particlesPixelShader: {
  17023. name: string;
  17024. shader: string;
  17025. };
  17026. }
  17027. declare module BABYLON {
  17028. /** @hidden */
  17029. export var clipPlaneVertexDeclaration: {
  17030. name: string;
  17031. shader: string;
  17032. };
  17033. }
  17034. declare module BABYLON {
  17035. /** @hidden */
  17036. export var clipPlaneVertex: {
  17037. name: string;
  17038. shader: string;
  17039. };
  17040. }
  17041. declare module BABYLON {
  17042. /** @hidden */
  17043. export var particlesVertexShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module BABYLON {
  17049. /**
  17050. * This represents a particle system in Babylon.
  17051. * 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.
  17052. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17053. * @example https://doc.babylonjs.com/babylon101/particles
  17054. */
  17055. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17056. /**
  17057. * Billboard mode will only apply to Y axis
  17058. */
  17059. static readonly BILLBOARDMODE_Y: number;
  17060. /**
  17061. * Billboard mode will apply to all axes
  17062. */
  17063. static readonly BILLBOARDMODE_ALL: number;
  17064. /**
  17065. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17066. */
  17067. static readonly BILLBOARDMODE_STRETCHED: number;
  17068. /**
  17069. * This function can be defined to provide custom update for active particles.
  17070. * This function will be called instead of regular update (age, position, color, etc.).
  17071. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17072. */
  17073. updateFunction: (particles: Particle[]) => void;
  17074. private _emitterWorldMatrix;
  17075. /**
  17076. * This function can be defined to specify initial direction for every new particle.
  17077. * It by default use the emitterType defined function
  17078. */
  17079. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17080. /**
  17081. * This function can be defined to specify initial position for every new particle.
  17082. * It by default use the emitterType defined function
  17083. */
  17084. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17085. /**
  17086. * @hidden
  17087. */
  17088. _inheritedVelocityOffset: Vector3;
  17089. /**
  17090. * An event triggered when the system is disposed
  17091. */
  17092. onDisposeObservable: Observable<ParticleSystem>;
  17093. private _onDisposeObserver;
  17094. /**
  17095. * Sets a callback that will be triggered when the system is disposed
  17096. */
  17097. onDispose: () => void;
  17098. private _particles;
  17099. private _epsilon;
  17100. private _capacity;
  17101. private _stockParticles;
  17102. private _newPartsExcess;
  17103. private _vertexData;
  17104. private _vertexBuffer;
  17105. private _vertexBuffers;
  17106. private _spriteBuffer;
  17107. private _indexBuffer;
  17108. private _effect;
  17109. private _customEffect;
  17110. private _cachedDefines;
  17111. private _scaledColorStep;
  17112. private _colorDiff;
  17113. private _scaledDirection;
  17114. private _scaledGravity;
  17115. private _currentRenderId;
  17116. private _alive;
  17117. private _useInstancing;
  17118. private _started;
  17119. private _stopped;
  17120. private _actualFrame;
  17121. private _scaledUpdateSpeed;
  17122. private _vertexBufferSize;
  17123. /** @hidden */
  17124. _currentEmitRateGradient: Nullable<FactorGradient>;
  17125. /** @hidden */
  17126. _currentEmitRate1: number;
  17127. /** @hidden */
  17128. _currentEmitRate2: number;
  17129. /** @hidden */
  17130. _currentStartSizeGradient: Nullable<FactorGradient>;
  17131. /** @hidden */
  17132. _currentStartSize1: number;
  17133. /** @hidden */
  17134. _currentStartSize2: number;
  17135. private readonly _rawTextureWidth;
  17136. private _rampGradientsTexture;
  17137. private _useRampGradients;
  17138. /** Gets or sets a boolean indicating that ramp gradients must be used
  17139. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17140. */
  17141. useRampGradients: boolean;
  17142. /**
  17143. * 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.
  17144. * 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: [])
  17145. */
  17146. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17147. private _subEmitters;
  17148. /**
  17149. * @hidden
  17150. * If the particle systems emitter should be disposed when the particle system is disposed
  17151. */
  17152. _disposeEmitterOnDispose: boolean;
  17153. /**
  17154. * The current active Sub-systems, this property is used by the root particle system only.
  17155. */
  17156. activeSubSystems: Array<ParticleSystem>;
  17157. private _rootParticleSystem;
  17158. /**
  17159. * Gets the current list of active particles
  17160. */
  17161. readonly particles: Particle[];
  17162. /**
  17163. * Returns the string "ParticleSystem"
  17164. * @returns a string containing the class name
  17165. */
  17166. getClassName(): string;
  17167. /**
  17168. * Instantiates a particle system.
  17169. * 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.
  17170. * @param name The name of the particle system
  17171. * @param capacity The max number of particles alive at the same time
  17172. * @param scene The scene the particle system belongs to
  17173. * @param customEffect a custom effect used to change the way particles are rendered by default
  17174. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17175. * @param epsilon Offset used to render the particles
  17176. */
  17177. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17178. private _addFactorGradient;
  17179. private _removeFactorGradient;
  17180. /**
  17181. * Adds a new life time gradient
  17182. * @param gradient defines the gradient to use (between 0 and 1)
  17183. * @param factor defines the life time factor to affect to the specified gradient
  17184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17185. * @returns the current particle system
  17186. */
  17187. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17188. /**
  17189. * Remove a specific life time gradient
  17190. * @param gradient defines the gradient to remove
  17191. * @returns the current particle system
  17192. */
  17193. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17194. /**
  17195. * Adds a new size gradient
  17196. * @param gradient defines the gradient to use (between 0 and 1)
  17197. * @param factor defines the size factor to affect to the specified gradient
  17198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17199. * @returns the current particle system
  17200. */
  17201. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17202. /**
  17203. * Remove a specific size gradient
  17204. * @param gradient defines the gradient to remove
  17205. * @returns the current particle system
  17206. */
  17207. removeSizeGradient(gradient: number): IParticleSystem;
  17208. /**
  17209. * Adds a new color remap gradient
  17210. * @param gradient defines the gradient to use (between 0 and 1)
  17211. * @param min defines the color remap minimal range
  17212. * @param max defines the color remap maximal range
  17213. * @returns the current particle system
  17214. */
  17215. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17216. /**
  17217. * Remove a specific color remap gradient
  17218. * @param gradient defines the gradient to remove
  17219. * @returns the current particle system
  17220. */
  17221. removeColorRemapGradient(gradient: number): IParticleSystem;
  17222. /**
  17223. * Adds a new alpha remap gradient
  17224. * @param gradient defines the gradient to use (between 0 and 1)
  17225. * @param min defines the alpha remap minimal range
  17226. * @param max defines the alpha remap maximal range
  17227. * @returns the current particle system
  17228. */
  17229. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17230. /**
  17231. * Remove a specific alpha remap gradient
  17232. * @param gradient defines the gradient to remove
  17233. * @returns the current particle system
  17234. */
  17235. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17236. /**
  17237. * Adds a new angular speed gradient
  17238. * @param gradient defines the gradient to use (between 0 and 1)
  17239. * @param factor defines the angular speed to affect to the specified gradient
  17240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17241. * @returns the current particle system
  17242. */
  17243. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17244. /**
  17245. * Remove a specific angular speed gradient
  17246. * @param gradient defines the gradient to remove
  17247. * @returns the current particle system
  17248. */
  17249. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17250. /**
  17251. * Adds a new velocity gradient
  17252. * @param gradient defines the gradient to use (between 0 and 1)
  17253. * @param factor defines the velocity to affect to the specified gradient
  17254. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17255. * @returns the current particle system
  17256. */
  17257. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17258. /**
  17259. * Remove a specific velocity gradient
  17260. * @param gradient defines the gradient to remove
  17261. * @returns the current particle system
  17262. */
  17263. removeVelocityGradient(gradient: number): IParticleSystem;
  17264. /**
  17265. * Adds a new limit velocity gradient
  17266. * @param gradient defines the gradient to use (between 0 and 1)
  17267. * @param factor defines the limit velocity value to affect to the specified gradient
  17268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17269. * @returns the current particle system
  17270. */
  17271. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17272. /**
  17273. * Remove a specific limit velocity gradient
  17274. * @param gradient defines the gradient to remove
  17275. * @returns the current particle system
  17276. */
  17277. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17278. /**
  17279. * Adds a new drag gradient
  17280. * @param gradient defines the gradient to use (between 0 and 1)
  17281. * @param factor defines the drag value to affect to the specified gradient
  17282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17283. * @returns the current particle system
  17284. */
  17285. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17286. /**
  17287. * Remove a specific drag gradient
  17288. * @param gradient defines the gradient to remove
  17289. * @returns the current particle system
  17290. */
  17291. removeDragGradient(gradient: number): IParticleSystem;
  17292. /**
  17293. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17294. * @param gradient defines the gradient to use (between 0 and 1)
  17295. * @param factor defines the emit rate value to affect to the specified gradient
  17296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17297. * @returns the current particle system
  17298. */
  17299. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17300. /**
  17301. * Remove a specific emit rate gradient
  17302. * @param gradient defines the gradient to remove
  17303. * @returns the current particle system
  17304. */
  17305. removeEmitRateGradient(gradient: number): IParticleSystem;
  17306. /**
  17307. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17308. * @param gradient defines the gradient to use (between 0 and 1)
  17309. * @param factor defines the start size value to affect to the specified gradient
  17310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17311. * @returns the current particle system
  17312. */
  17313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17314. /**
  17315. * Remove a specific start size gradient
  17316. * @param gradient defines the gradient to remove
  17317. * @returns the current particle system
  17318. */
  17319. removeStartSizeGradient(gradient: number): IParticleSystem;
  17320. private _createRampGradientTexture;
  17321. /**
  17322. * Gets the current list of ramp gradients.
  17323. * You must use addRampGradient and removeRampGradient to udpate this list
  17324. * @returns the list of ramp gradients
  17325. */
  17326. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17327. /**
  17328. * Adds a new ramp gradient used to remap particle colors
  17329. * @param gradient defines the gradient to use (between 0 and 1)
  17330. * @param color defines the color to affect to the specified gradient
  17331. * @returns the current particle system
  17332. */
  17333. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17334. /**
  17335. * Remove a specific ramp gradient
  17336. * @param gradient defines the gradient to remove
  17337. * @returns the current particle system
  17338. */
  17339. removeRampGradient(gradient: number): ParticleSystem;
  17340. /**
  17341. * Adds a new color gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param color1 defines the color to affect to the specified gradient
  17344. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17345. * @returns this particle system
  17346. */
  17347. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17348. /**
  17349. * Remove a specific color gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns this particle system
  17352. */
  17353. removeColorGradient(gradient: number): IParticleSystem;
  17354. private _fetchR;
  17355. protected _reset(): void;
  17356. private _resetEffect;
  17357. private _createVertexBuffers;
  17358. private _createIndexBuffer;
  17359. /**
  17360. * Gets the maximum number of particles active at the same time.
  17361. * @returns The max number of active particles.
  17362. */
  17363. getCapacity(): number;
  17364. /**
  17365. * Gets whether there are still active particles in the system.
  17366. * @returns True if it is alive, otherwise false.
  17367. */
  17368. isAlive(): boolean;
  17369. /**
  17370. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17371. * @returns True if it has been started, otherwise false.
  17372. */
  17373. isStarted(): boolean;
  17374. private _prepareSubEmitterInternalArray;
  17375. /**
  17376. * Starts the particle system and begins to emit
  17377. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17378. */
  17379. start(delay?: number): void;
  17380. /**
  17381. * Stops the particle system.
  17382. * @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.
  17383. */
  17384. stop(stopSubEmitters?: boolean): void;
  17385. /**
  17386. * Remove all active particles
  17387. */
  17388. reset(): void;
  17389. /**
  17390. * @hidden (for internal use only)
  17391. */
  17392. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17393. /**
  17394. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17395. * Its lifetime will start back at 0.
  17396. */
  17397. recycleParticle: (particle: Particle) => void;
  17398. private _stopSubEmitters;
  17399. private _createParticle;
  17400. private _removeFromRoot;
  17401. private _emitFromParticle;
  17402. private _update;
  17403. /** @hidden */
  17404. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17405. /** @hidden */
  17406. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17407. /** @hidden */
  17408. private _getEffect;
  17409. /**
  17410. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17411. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17412. */
  17413. animate(preWarmOnly?: boolean): void;
  17414. private _appendParticleVertices;
  17415. /**
  17416. * Rebuilds the particle system.
  17417. */
  17418. rebuild(): void;
  17419. /**
  17420. * Is this system ready to be used/rendered
  17421. * @return true if the system is ready
  17422. */
  17423. isReady(): boolean;
  17424. private _render;
  17425. /**
  17426. * Renders the particle system in its current state.
  17427. * @returns the current number of particles
  17428. */
  17429. render(): number;
  17430. /**
  17431. * Disposes the particle system and free the associated resources
  17432. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17433. */
  17434. dispose(disposeTexture?: boolean): void;
  17435. /**
  17436. * Clones the particle system.
  17437. * @param name The name of the cloned object
  17438. * @param newEmitter The new emitter to use
  17439. * @returns the cloned particle system
  17440. */
  17441. clone(name: string, newEmitter: any): ParticleSystem;
  17442. /**
  17443. * Serializes the particle system to a JSON object.
  17444. * @returns the JSON object
  17445. */
  17446. serialize(): any;
  17447. /** @hidden */
  17448. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17449. /** @hidden */
  17450. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17451. /**
  17452. * Parses a JSON object to create a particle system.
  17453. * @param parsedParticleSystem The JSON object to parse
  17454. * @param scene The scene to create the particle system in
  17455. * @param rootUrl The root url to use to load external dependencies like texture
  17456. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17457. * @returns the Parsed particle system
  17458. */
  17459. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17460. }
  17461. }
  17462. declare module BABYLON {
  17463. /**
  17464. * A particle represents one of the element emitted by a particle system.
  17465. * This is mainly define by its coordinates, direction, velocity and age.
  17466. */
  17467. export class Particle {
  17468. /**
  17469. * The particle system the particle belongs to.
  17470. */
  17471. particleSystem: ParticleSystem;
  17472. private static _Count;
  17473. /**
  17474. * Unique ID of the particle
  17475. */
  17476. id: number;
  17477. /**
  17478. * The world position of the particle in the scene.
  17479. */
  17480. position: Vector3;
  17481. /**
  17482. * The world direction of the particle in the scene.
  17483. */
  17484. direction: Vector3;
  17485. /**
  17486. * The color of the particle.
  17487. */
  17488. color: Color4;
  17489. /**
  17490. * The color change of the particle per step.
  17491. */
  17492. colorStep: Color4;
  17493. /**
  17494. * Defines how long will the life of the particle be.
  17495. */
  17496. lifeTime: number;
  17497. /**
  17498. * The current age of the particle.
  17499. */
  17500. age: number;
  17501. /**
  17502. * The current size of the particle.
  17503. */
  17504. size: number;
  17505. /**
  17506. * The current scale of the particle.
  17507. */
  17508. scale: Vector2;
  17509. /**
  17510. * The current angle of the particle.
  17511. */
  17512. angle: number;
  17513. /**
  17514. * Defines how fast is the angle changing.
  17515. */
  17516. angularSpeed: number;
  17517. /**
  17518. * Defines the cell index used by the particle to be rendered from a sprite.
  17519. */
  17520. cellIndex: number;
  17521. /**
  17522. * The information required to support color remapping
  17523. */
  17524. remapData: Vector4;
  17525. /** @hidden */
  17526. _randomCellOffset?: number;
  17527. /** @hidden */
  17528. _initialDirection: Nullable<Vector3>;
  17529. /** @hidden */
  17530. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17531. /** @hidden */
  17532. _initialStartSpriteCellID: number;
  17533. /** @hidden */
  17534. _initialEndSpriteCellID: number;
  17535. /** @hidden */
  17536. _currentColorGradient: Nullable<ColorGradient>;
  17537. /** @hidden */
  17538. _currentColor1: Color4;
  17539. /** @hidden */
  17540. _currentColor2: Color4;
  17541. /** @hidden */
  17542. _currentSizeGradient: Nullable<FactorGradient>;
  17543. /** @hidden */
  17544. _currentSize1: number;
  17545. /** @hidden */
  17546. _currentSize2: number;
  17547. /** @hidden */
  17548. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17549. /** @hidden */
  17550. _currentAngularSpeed1: number;
  17551. /** @hidden */
  17552. _currentAngularSpeed2: number;
  17553. /** @hidden */
  17554. _currentVelocityGradient: Nullable<FactorGradient>;
  17555. /** @hidden */
  17556. _currentVelocity1: number;
  17557. /** @hidden */
  17558. _currentVelocity2: number;
  17559. /** @hidden */
  17560. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17561. /** @hidden */
  17562. _currentLimitVelocity1: number;
  17563. /** @hidden */
  17564. _currentLimitVelocity2: number;
  17565. /** @hidden */
  17566. _currentDragGradient: Nullable<FactorGradient>;
  17567. /** @hidden */
  17568. _currentDrag1: number;
  17569. /** @hidden */
  17570. _currentDrag2: number;
  17571. /** @hidden */
  17572. _randomNoiseCoordinates1: Vector3;
  17573. /** @hidden */
  17574. _randomNoiseCoordinates2: Vector3;
  17575. /**
  17576. * Creates a new instance Particle
  17577. * @param particleSystem the particle system the particle belongs to
  17578. */
  17579. constructor(
  17580. /**
  17581. * The particle system the particle belongs to.
  17582. */
  17583. particleSystem: ParticleSystem);
  17584. private updateCellInfoFromSystem;
  17585. /**
  17586. * Defines how the sprite cell index is updated for the particle
  17587. */
  17588. updateCellIndex(): void;
  17589. /** @hidden */
  17590. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17591. /** @hidden */
  17592. _inheritParticleInfoToSubEmitters(): void;
  17593. /** @hidden */
  17594. _reset(): void;
  17595. /**
  17596. * Copy the properties of particle to another one.
  17597. * @param other the particle to copy the information to.
  17598. */
  17599. copyTo(other: Particle): void;
  17600. }
  17601. }
  17602. declare module BABYLON {
  17603. /**
  17604. * Particle emitter represents a volume emitting particles.
  17605. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17606. */
  17607. export interface IParticleEmitterType {
  17608. /**
  17609. * Called by the particle System when the direction is computed for the created particle.
  17610. * @param worldMatrix is the world matrix of the particle system
  17611. * @param directionToUpdate is the direction vector to update with the result
  17612. * @param particle is the particle we are computed the direction for
  17613. */
  17614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17615. /**
  17616. * Called by the particle System when the position is computed for the created particle.
  17617. * @param worldMatrix is the world matrix of the particle system
  17618. * @param positionToUpdate is the position vector to update with the result
  17619. * @param particle is the particle we are computed the position for
  17620. */
  17621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17622. /**
  17623. * Clones the current emitter and returns a copy of it
  17624. * @returns the new emitter
  17625. */
  17626. clone(): IParticleEmitterType;
  17627. /**
  17628. * Called by the GPUParticleSystem to setup the update shader
  17629. * @param effect defines the update shader
  17630. */
  17631. applyToShader(effect: Effect): void;
  17632. /**
  17633. * Returns a string to use to update the GPU particles update shader
  17634. * @returns the effect defines string
  17635. */
  17636. getEffectDefines(): string;
  17637. /**
  17638. * Returns a string representing the class name
  17639. * @returns a string containing the class name
  17640. */
  17641. getClassName(): string;
  17642. /**
  17643. * Serializes the particle system to a JSON object.
  17644. * @returns the JSON object
  17645. */
  17646. serialize(): any;
  17647. /**
  17648. * Parse properties from a JSON object
  17649. * @param serializationObject defines the JSON object
  17650. */
  17651. parse(serializationObject: any): void;
  17652. }
  17653. }
  17654. declare module BABYLON {
  17655. /**
  17656. * Particle emitter emitting particles from the inside of a box.
  17657. * It emits the particles randomly between 2 given directions.
  17658. */
  17659. export class BoxParticleEmitter implements IParticleEmitterType {
  17660. /**
  17661. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17662. */
  17663. direction1: Vector3;
  17664. /**
  17665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17666. */
  17667. direction2: Vector3;
  17668. /**
  17669. * 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.
  17670. */
  17671. minEmitBox: Vector3;
  17672. /**
  17673. * 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.
  17674. */
  17675. maxEmitBox: Vector3;
  17676. /**
  17677. * Creates a new instance BoxParticleEmitter
  17678. */
  17679. constructor();
  17680. /**
  17681. * Called by the particle System when the direction is computed for the created particle.
  17682. * @param worldMatrix is the world matrix of the particle system
  17683. * @param directionToUpdate is the direction vector to update with the result
  17684. * @param particle is the particle we are computed the direction for
  17685. */
  17686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17687. /**
  17688. * Called by the particle System when the position is computed for the created particle.
  17689. * @param worldMatrix is the world matrix of the particle system
  17690. * @param positionToUpdate is the position vector to update with the result
  17691. * @param particle is the particle we are computed the position for
  17692. */
  17693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17694. /**
  17695. * Clones the current emitter and returns a copy of it
  17696. * @returns the new emitter
  17697. */
  17698. clone(): BoxParticleEmitter;
  17699. /**
  17700. * Called by the GPUParticleSystem to setup the update shader
  17701. * @param effect defines the update shader
  17702. */
  17703. applyToShader(effect: Effect): void;
  17704. /**
  17705. * Returns a string to use to update the GPU particles update shader
  17706. * @returns a string containng the defines string
  17707. */
  17708. getEffectDefines(): string;
  17709. /**
  17710. * Returns the string "BoxParticleEmitter"
  17711. * @returns a string containing the class name
  17712. */
  17713. getClassName(): string;
  17714. /**
  17715. * Serializes the particle system to a JSON object.
  17716. * @returns the JSON object
  17717. */
  17718. serialize(): any;
  17719. /**
  17720. * Parse properties from a JSON object
  17721. * @param serializationObject defines the JSON object
  17722. */
  17723. parse(serializationObject: any): void;
  17724. }
  17725. }
  17726. declare module BABYLON {
  17727. /**
  17728. * Particle emitter emitting particles from the inside of a cone.
  17729. * It emits the particles alongside the cone volume from the base to the particle.
  17730. * The emission direction might be randomized.
  17731. */
  17732. export class ConeParticleEmitter implements IParticleEmitterType {
  17733. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17734. directionRandomizer: number;
  17735. private _radius;
  17736. private _angle;
  17737. private _height;
  17738. /**
  17739. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17740. */
  17741. radiusRange: number;
  17742. /**
  17743. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17744. */
  17745. heightRange: number;
  17746. /**
  17747. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17748. */
  17749. emitFromSpawnPointOnly: boolean;
  17750. /**
  17751. * Gets or sets the radius of the emission cone
  17752. */
  17753. radius: number;
  17754. /**
  17755. * Gets or sets the angle of the emission cone
  17756. */
  17757. angle: number;
  17758. private _buildHeight;
  17759. /**
  17760. * Creates a new instance ConeParticleEmitter
  17761. * @param radius the radius of the emission cone (1 by default)
  17762. * @param angle the cone base angle (PI by default)
  17763. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17764. */
  17765. constructor(radius?: number, angle?: number,
  17766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17767. directionRandomizer?: number);
  17768. /**
  17769. * Called by the particle System when the direction is computed for the created particle.
  17770. * @param worldMatrix is the world matrix of the particle system
  17771. * @param directionToUpdate is the direction vector to update with the result
  17772. * @param particle is the particle we are computed the direction for
  17773. */
  17774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17775. /**
  17776. * Called by the particle System when the position is computed for the created particle.
  17777. * @param worldMatrix is the world matrix of the particle system
  17778. * @param positionToUpdate is the position vector to update with the result
  17779. * @param particle is the particle we are computed the position for
  17780. */
  17781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17782. /**
  17783. * Clones the current emitter and returns a copy of it
  17784. * @returns the new emitter
  17785. */
  17786. clone(): ConeParticleEmitter;
  17787. /**
  17788. * Called by the GPUParticleSystem to setup the update shader
  17789. * @param effect defines the update shader
  17790. */
  17791. applyToShader(effect: Effect): void;
  17792. /**
  17793. * Returns a string to use to update the GPU particles update shader
  17794. * @returns a string containng the defines string
  17795. */
  17796. getEffectDefines(): string;
  17797. /**
  17798. * Returns the string "ConeParticleEmitter"
  17799. * @returns a string containing the class name
  17800. */
  17801. getClassName(): string;
  17802. /**
  17803. * Serializes the particle system to a JSON object.
  17804. * @returns the JSON object
  17805. */
  17806. serialize(): any;
  17807. /**
  17808. * Parse properties from a JSON object
  17809. * @param serializationObject defines the JSON object
  17810. */
  17811. parse(serializationObject: any): void;
  17812. }
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * Particle emitter emitting particles from the inside of a cylinder.
  17817. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17818. */
  17819. export class CylinderParticleEmitter implements IParticleEmitterType {
  17820. /**
  17821. * The radius of the emission cylinder.
  17822. */
  17823. radius: number;
  17824. /**
  17825. * The height of the emission cylinder.
  17826. */
  17827. height: number;
  17828. /**
  17829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17830. */
  17831. radiusRange: number;
  17832. /**
  17833. * How much to randomize the particle direction [0-1].
  17834. */
  17835. directionRandomizer: number;
  17836. /**
  17837. * Creates a new instance CylinderParticleEmitter
  17838. * @param radius the radius of the emission cylinder (1 by default)
  17839. * @param height the height of the emission cylinder (1 by default)
  17840. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17841. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17842. */
  17843. constructor(
  17844. /**
  17845. * The radius of the emission cylinder.
  17846. */
  17847. radius?: number,
  17848. /**
  17849. * The height of the emission cylinder.
  17850. */
  17851. height?: number,
  17852. /**
  17853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17854. */
  17855. radiusRange?: number,
  17856. /**
  17857. * How much to randomize the particle direction [0-1].
  17858. */
  17859. directionRandomizer?: number);
  17860. /**
  17861. * Called by the particle System when the direction is computed for the created particle.
  17862. * @param worldMatrix is the world matrix of the particle system
  17863. * @param directionToUpdate is the direction vector to update with the result
  17864. * @param particle is the particle we are computed the direction for
  17865. */
  17866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17867. /**
  17868. * Called by the particle System when the position is computed for the created particle.
  17869. * @param worldMatrix is the world matrix of the particle system
  17870. * @param positionToUpdate is the position vector to update with the result
  17871. * @param particle is the particle we are computed the position for
  17872. */
  17873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17874. /**
  17875. * Clones the current emitter and returns a copy of it
  17876. * @returns the new emitter
  17877. */
  17878. clone(): CylinderParticleEmitter;
  17879. /**
  17880. * Called by the GPUParticleSystem to setup the update shader
  17881. * @param effect defines the update shader
  17882. */
  17883. applyToShader(effect: Effect): void;
  17884. /**
  17885. * Returns a string to use to update the GPU particles update shader
  17886. * @returns a string containng the defines string
  17887. */
  17888. getEffectDefines(): string;
  17889. /**
  17890. * Returns the string "CylinderParticleEmitter"
  17891. * @returns a string containing the class name
  17892. */
  17893. getClassName(): string;
  17894. /**
  17895. * Serializes the particle system to a JSON object.
  17896. * @returns the JSON object
  17897. */
  17898. serialize(): any;
  17899. /**
  17900. * Parse properties from a JSON object
  17901. * @param serializationObject defines the JSON object
  17902. */
  17903. parse(serializationObject: any): void;
  17904. }
  17905. /**
  17906. * Particle emitter emitting particles from the inside of a cylinder.
  17907. * It emits the particles randomly between two vectors.
  17908. */
  17909. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17910. /**
  17911. * The min limit of the emission direction.
  17912. */
  17913. direction1: Vector3;
  17914. /**
  17915. * The max limit of the emission direction.
  17916. */
  17917. direction2: Vector3;
  17918. /**
  17919. * Creates a new instance CylinderDirectedParticleEmitter
  17920. * @param radius the radius of the emission cylinder (1 by default)
  17921. * @param height the height of the emission cylinder (1 by default)
  17922. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17923. * @param direction1 the min limit of the emission direction (up vector by default)
  17924. * @param direction2 the max limit of the emission direction (up vector by default)
  17925. */
  17926. constructor(radius?: number, height?: number, radiusRange?: number,
  17927. /**
  17928. * The min limit of the emission direction.
  17929. */
  17930. direction1?: Vector3,
  17931. /**
  17932. * The max limit of the emission direction.
  17933. */
  17934. direction2?: Vector3);
  17935. /**
  17936. * Called by the particle System when the direction is computed for the created particle.
  17937. * @param worldMatrix is the world matrix of the particle system
  17938. * @param directionToUpdate is the direction vector to update with the result
  17939. * @param particle is the particle we are computed the direction for
  17940. */
  17941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17942. /**
  17943. * Clones the current emitter and returns a copy of it
  17944. * @returns the new emitter
  17945. */
  17946. clone(): CylinderDirectedParticleEmitter;
  17947. /**
  17948. * Called by the GPUParticleSystem to setup the update shader
  17949. * @param effect defines the update shader
  17950. */
  17951. applyToShader(effect: Effect): void;
  17952. /**
  17953. * Returns a string to use to update the GPU particles update shader
  17954. * @returns a string containng the defines string
  17955. */
  17956. getEffectDefines(): string;
  17957. /**
  17958. * Returns the string "CylinderDirectedParticleEmitter"
  17959. * @returns a string containing the class name
  17960. */
  17961. getClassName(): string;
  17962. /**
  17963. * Serializes the particle system to a JSON object.
  17964. * @returns the JSON object
  17965. */
  17966. serialize(): any;
  17967. /**
  17968. * Parse properties from a JSON object
  17969. * @param serializationObject defines the JSON object
  17970. */
  17971. parse(serializationObject: any): void;
  17972. }
  17973. }
  17974. declare module BABYLON {
  17975. /**
  17976. * Particle emitter emitting particles from the inside of a hemisphere.
  17977. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17978. */
  17979. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17980. /**
  17981. * The radius of the emission hemisphere.
  17982. */
  17983. radius: number;
  17984. /**
  17985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17986. */
  17987. radiusRange: number;
  17988. /**
  17989. * How much to randomize the particle direction [0-1].
  17990. */
  17991. directionRandomizer: number;
  17992. /**
  17993. * Creates a new instance HemisphericParticleEmitter
  17994. * @param radius the radius of the emission hemisphere (1 by default)
  17995. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17997. */
  17998. constructor(
  17999. /**
  18000. * The radius of the emission hemisphere.
  18001. */
  18002. radius?: number,
  18003. /**
  18004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18005. */
  18006. radiusRange?: number,
  18007. /**
  18008. * How much to randomize the particle direction [0-1].
  18009. */
  18010. directionRandomizer?: number);
  18011. /**
  18012. * Called by the particle System when the direction is computed for the created particle.
  18013. * @param worldMatrix is the world matrix of the particle system
  18014. * @param directionToUpdate is the direction vector to update with the result
  18015. * @param particle is the particle we are computed the direction for
  18016. */
  18017. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18018. /**
  18019. * Called by the particle System when the position is computed for the created particle.
  18020. * @param worldMatrix is the world matrix of the particle system
  18021. * @param positionToUpdate is the position vector to update with the result
  18022. * @param particle is the particle we are computed the position for
  18023. */
  18024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18025. /**
  18026. * Clones the current emitter and returns a copy of it
  18027. * @returns the new emitter
  18028. */
  18029. clone(): HemisphericParticleEmitter;
  18030. /**
  18031. * Called by the GPUParticleSystem to setup the update shader
  18032. * @param effect defines the update shader
  18033. */
  18034. applyToShader(effect: Effect): void;
  18035. /**
  18036. * Returns a string to use to update the GPU particles update shader
  18037. * @returns a string containng the defines string
  18038. */
  18039. getEffectDefines(): string;
  18040. /**
  18041. * Returns the string "HemisphericParticleEmitter"
  18042. * @returns a string containing the class name
  18043. */
  18044. getClassName(): string;
  18045. /**
  18046. * Serializes the particle system to a JSON object.
  18047. * @returns the JSON object
  18048. */
  18049. serialize(): any;
  18050. /**
  18051. * Parse properties from a JSON object
  18052. * @param serializationObject defines the JSON object
  18053. */
  18054. parse(serializationObject: any): void;
  18055. }
  18056. }
  18057. declare module BABYLON {
  18058. /**
  18059. * Particle emitter emitting particles from a point.
  18060. * It emits the particles randomly between 2 given directions.
  18061. */
  18062. export class PointParticleEmitter implements IParticleEmitterType {
  18063. /**
  18064. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18065. */
  18066. direction1: Vector3;
  18067. /**
  18068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18069. */
  18070. direction2: Vector3;
  18071. /**
  18072. * Creates a new instance PointParticleEmitter
  18073. */
  18074. constructor();
  18075. /**
  18076. * Called by the particle System when the direction is computed for the created particle.
  18077. * @param worldMatrix is the world matrix of the particle system
  18078. * @param directionToUpdate is the direction vector to update with the result
  18079. * @param particle is the particle we are computed the direction for
  18080. */
  18081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18082. /**
  18083. * Called by the particle System when the position is computed for the created particle.
  18084. * @param worldMatrix is the world matrix of the particle system
  18085. * @param positionToUpdate is the position vector to update with the result
  18086. * @param particle is the particle we are computed the position for
  18087. */
  18088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18089. /**
  18090. * Clones the current emitter and returns a copy of it
  18091. * @returns the new emitter
  18092. */
  18093. clone(): PointParticleEmitter;
  18094. /**
  18095. * Called by the GPUParticleSystem to setup the update shader
  18096. * @param effect defines the update shader
  18097. */
  18098. applyToShader(effect: Effect): void;
  18099. /**
  18100. * Returns a string to use to update the GPU particles update shader
  18101. * @returns a string containng the defines string
  18102. */
  18103. getEffectDefines(): string;
  18104. /**
  18105. * Returns the string "PointParticleEmitter"
  18106. * @returns a string containing the class name
  18107. */
  18108. getClassName(): string;
  18109. /**
  18110. * Serializes the particle system to a JSON object.
  18111. * @returns the JSON object
  18112. */
  18113. serialize(): any;
  18114. /**
  18115. * Parse properties from a JSON object
  18116. * @param serializationObject defines the JSON object
  18117. */
  18118. parse(serializationObject: any): void;
  18119. }
  18120. }
  18121. declare module BABYLON {
  18122. /**
  18123. * Particle emitter emitting particles from the inside of a sphere.
  18124. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18125. */
  18126. export class SphereParticleEmitter implements IParticleEmitterType {
  18127. /**
  18128. * The radius of the emission sphere.
  18129. */
  18130. radius: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance SphereParticleEmitter
  18141. * @param radius the radius of the emission sphere (1 by default)
  18142. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18143. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18144. */
  18145. constructor(
  18146. /**
  18147. * The radius of the emission sphere.
  18148. */
  18149. radius?: number,
  18150. /**
  18151. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18152. */
  18153. radiusRange?: number,
  18154. /**
  18155. * How much to randomize the particle direction [0-1].
  18156. */
  18157. directionRandomizer?: number);
  18158. /**
  18159. * Called by the particle System when the direction is computed for the created particle.
  18160. * @param worldMatrix is the world matrix of the particle system
  18161. * @param directionToUpdate is the direction vector to update with the result
  18162. * @param particle is the particle we are computed the direction for
  18163. */
  18164. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18165. /**
  18166. * Called by the particle System when the position is computed for the created particle.
  18167. * @param worldMatrix is the world matrix of the particle system
  18168. * @param positionToUpdate is the position vector to update with the result
  18169. * @param particle is the particle we are computed the position for
  18170. */
  18171. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18172. /**
  18173. * Clones the current emitter and returns a copy of it
  18174. * @returns the new emitter
  18175. */
  18176. clone(): SphereParticleEmitter;
  18177. /**
  18178. * Called by the GPUParticleSystem to setup the update shader
  18179. * @param effect defines the update shader
  18180. */
  18181. applyToShader(effect: Effect): void;
  18182. /**
  18183. * Returns a string to use to update the GPU particles update shader
  18184. * @returns a string containng the defines string
  18185. */
  18186. getEffectDefines(): string;
  18187. /**
  18188. * Returns the string "SphereParticleEmitter"
  18189. * @returns a string containing the class name
  18190. */
  18191. getClassName(): string;
  18192. /**
  18193. * Serializes the particle system to a JSON object.
  18194. * @returns the JSON object
  18195. */
  18196. serialize(): any;
  18197. /**
  18198. * Parse properties from a JSON object
  18199. * @param serializationObject defines the JSON object
  18200. */
  18201. parse(serializationObject: any): void;
  18202. }
  18203. /**
  18204. * Particle emitter emitting particles from the inside of a sphere.
  18205. * It emits the particles randomly between two vectors.
  18206. */
  18207. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18208. /**
  18209. * The min limit of the emission direction.
  18210. */
  18211. direction1: Vector3;
  18212. /**
  18213. * The max limit of the emission direction.
  18214. */
  18215. direction2: Vector3;
  18216. /**
  18217. * Creates a new instance SphereDirectedParticleEmitter
  18218. * @param radius the radius of the emission sphere (1 by default)
  18219. * @param direction1 the min limit of the emission direction (up vector by default)
  18220. * @param direction2 the max limit of the emission direction (up vector by default)
  18221. */
  18222. constructor(radius?: number,
  18223. /**
  18224. * The min limit of the emission direction.
  18225. */
  18226. direction1?: Vector3,
  18227. /**
  18228. * The max limit of the emission direction.
  18229. */
  18230. direction2?: Vector3);
  18231. /**
  18232. * Called by the particle System when the direction is computed for the created particle.
  18233. * @param worldMatrix is the world matrix of the particle system
  18234. * @param directionToUpdate is the direction vector to update with the result
  18235. * @param particle is the particle we are computed the direction for
  18236. */
  18237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18238. /**
  18239. * Clones the current emitter and returns a copy of it
  18240. * @returns the new emitter
  18241. */
  18242. clone(): SphereDirectedParticleEmitter;
  18243. /**
  18244. * Called by the GPUParticleSystem to setup the update shader
  18245. * @param effect defines the update shader
  18246. */
  18247. applyToShader(effect: Effect): void;
  18248. /**
  18249. * Returns a string to use to update the GPU particles update shader
  18250. * @returns a string containng the defines string
  18251. */
  18252. getEffectDefines(): string;
  18253. /**
  18254. * Returns the string "SphereDirectedParticleEmitter"
  18255. * @returns a string containing the class name
  18256. */
  18257. getClassName(): string;
  18258. /**
  18259. * Serializes the particle system to a JSON object.
  18260. * @returns the JSON object
  18261. */
  18262. serialize(): any;
  18263. /**
  18264. * Parse properties from a JSON object
  18265. * @param serializationObject defines the JSON object
  18266. */
  18267. parse(serializationObject: any): void;
  18268. }
  18269. }
  18270. declare module BABYLON {
  18271. /**
  18272. * Interface representing a particle system in Babylon.js.
  18273. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18274. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18275. */
  18276. export interface IParticleSystem {
  18277. /**
  18278. * List of animations used by the particle system.
  18279. */
  18280. animations: Animation[];
  18281. /**
  18282. * The id of the Particle system.
  18283. */
  18284. id: string;
  18285. /**
  18286. * The name of the Particle system.
  18287. */
  18288. name: string;
  18289. /**
  18290. * The emitter represents the Mesh or position we are attaching the particle system to.
  18291. */
  18292. emitter: Nullable<AbstractMesh | Vector3>;
  18293. /**
  18294. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18295. */
  18296. isBillboardBased: boolean;
  18297. /**
  18298. * The rendering group used by the Particle system to chose when to render.
  18299. */
  18300. renderingGroupId: number;
  18301. /**
  18302. * The layer mask we are rendering the particles through.
  18303. */
  18304. layerMask: number;
  18305. /**
  18306. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18307. */
  18308. updateSpeed: number;
  18309. /**
  18310. * The amount of time the particle system is running (depends of the overall update speed).
  18311. */
  18312. targetStopDuration: number;
  18313. /**
  18314. * The texture used to render each particle. (this can be a spritesheet)
  18315. */
  18316. particleTexture: Nullable<Texture>;
  18317. /**
  18318. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18319. */
  18320. blendMode: number;
  18321. /**
  18322. * Minimum life time of emitting particles.
  18323. */
  18324. minLifeTime: number;
  18325. /**
  18326. * Maximum life time of emitting particles.
  18327. */
  18328. maxLifeTime: number;
  18329. /**
  18330. * Minimum Size of emitting particles.
  18331. */
  18332. minSize: number;
  18333. /**
  18334. * Maximum Size of emitting particles.
  18335. */
  18336. maxSize: number;
  18337. /**
  18338. * Minimum scale of emitting particles on X axis.
  18339. */
  18340. minScaleX: number;
  18341. /**
  18342. * Maximum scale of emitting particles on X axis.
  18343. */
  18344. maxScaleX: number;
  18345. /**
  18346. * Minimum scale of emitting particles on Y axis.
  18347. */
  18348. minScaleY: number;
  18349. /**
  18350. * Maximum scale of emitting particles on Y axis.
  18351. */
  18352. maxScaleY: number;
  18353. /**
  18354. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18355. */
  18356. color1: Color4;
  18357. /**
  18358. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18359. */
  18360. color2: Color4;
  18361. /**
  18362. * Color the particle will have at the end of its lifetime.
  18363. */
  18364. colorDead: Color4;
  18365. /**
  18366. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18367. */
  18368. emitRate: number;
  18369. /**
  18370. * You can use gravity if you want to give an orientation to your particles.
  18371. */
  18372. gravity: Vector3;
  18373. /**
  18374. * Minimum power of emitting particles.
  18375. */
  18376. minEmitPower: number;
  18377. /**
  18378. * Maximum power of emitting particles.
  18379. */
  18380. maxEmitPower: number;
  18381. /**
  18382. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18383. */
  18384. minAngularSpeed: number;
  18385. /**
  18386. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18387. */
  18388. maxAngularSpeed: number;
  18389. /**
  18390. * Gets or sets the minimal initial rotation in radians.
  18391. */
  18392. minInitialRotation: number;
  18393. /**
  18394. * Gets or sets the maximal initial rotation in radians.
  18395. */
  18396. maxInitialRotation: number;
  18397. /**
  18398. * The particle emitter type defines the emitter used by the particle system.
  18399. * It can be for example box, sphere, or cone...
  18400. */
  18401. particleEmitterType: Nullable<IParticleEmitterType>;
  18402. /**
  18403. * Defines the delay in milliseconds before starting the system (0 by default)
  18404. */
  18405. startDelay: number;
  18406. /**
  18407. * 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
  18408. */
  18409. preWarmCycles: number;
  18410. /**
  18411. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18412. */
  18413. preWarmStepOffset: number;
  18414. /**
  18415. * 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)
  18416. */
  18417. spriteCellChangeSpeed: number;
  18418. /**
  18419. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18420. */
  18421. startSpriteCellID: number;
  18422. /**
  18423. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18424. */
  18425. endSpriteCellID: number;
  18426. /**
  18427. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18428. */
  18429. spriteCellWidth: number;
  18430. /**
  18431. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18432. */
  18433. spriteCellHeight: number;
  18434. /**
  18435. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18436. */
  18437. spriteRandomStartCell: boolean;
  18438. /**
  18439. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18440. */
  18441. isAnimationSheetEnabled: boolean;
  18442. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18443. translationPivot: Vector2;
  18444. /**
  18445. * Gets or sets a texture used to add random noise to particle positions
  18446. */
  18447. noiseTexture: Nullable<BaseTexture>;
  18448. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18449. noiseStrength: Vector3;
  18450. /**
  18451. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18452. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18453. */
  18454. billboardMode: number;
  18455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18456. limitVelocityDamping: number;
  18457. /**
  18458. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18459. */
  18460. beginAnimationOnStart: boolean;
  18461. /**
  18462. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18463. */
  18464. beginAnimationFrom: number;
  18465. /**
  18466. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18467. */
  18468. beginAnimationTo: number;
  18469. /**
  18470. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18471. */
  18472. beginAnimationLoop: boolean;
  18473. /**
  18474. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18475. */
  18476. disposeOnStop: boolean;
  18477. /**
  18478. * Gets the maximum number of particles active at the same time.
  18479. * @returns The max number of active particles.
  18480. */
  18481. getCapacity(): number;
  18482. /**
  18483. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18484. * @returns True if it has been started, otherwise false.
  18485. */
  18486. isStarted(): boolean;
  18487. /**
  18488. * Animates the particle system for this frame.
  18489. */
  18490. animate(): void;
  18491. /**
  18492. * Renders the particle system in its current state.
  18493. * @returns the current number of particles
  18494. */
  18495. render(): number;
  18496. /**
  18497. * Dispose the particle system and frees its associated resources.
  18498. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18499. */
  18500. dispose(disposeTexture?: boolean): void;
  18501. /**
  18502. * Clones the particle system.
  18503. * @param name The name of the cloned object
  18504. * @param newEmitter The new emitter to use
  18505. * @returns the cloned particle system
  18506. */
  18507. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18508. /**
  18509. * Serializes the particle system to a JSON object.
  18510. * @returns the JSON object
  18511. */
  18512. serialize(): any;
  18513. /**
  18514. * Rebuild the particle system
  18515. */
  18516. rebuild(): void;
  18517. /**
  18518. * Starts the particle system and begins to emit
  18519. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18520. */
  18521. start(delay?: number): void;
  18522. /**
  18523. * Stops the particle system.
  18524. */
  18525. stop(): void;
  18526. /**
  18527. * Remove all active particles
  18528. */
  18529. reset(): void;
  18530. /**
  18531. * Is this system ready to be used/rendered
  18532. * @return true if the system is ready
  18533. */
  18534. isReady(): boolean;
  18535. /**
  18536. * Adds a new color gradient
  18537. * @param gradient defines the gradient to use (between 0 and 1)
  18538. * @param color1 defines the color to affect to the specified gradient
  18539. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18540. * @returns the current particle system
  18541. */
  18542. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18543. /**
  18544. * Remove a specific color gradient
  18545. * @param gradient defines the gradient to remove
  18546. * @returns the current particle system
  18547. */
  18548. removeColorGradient(gradient: number): IParticleSystem;
  18549. /**
  18550. * Adds a new size gradient
  18551. * @param gradient defines the gradient to use (between 0 and 1)
  18552. * @param factor defines the size factor to affect to the specified gradient
  18553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18554. * @returns the current particle system
  18555. */
  18556. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18557. /**
  18558. * Remove a specific size gradient
  18559. * @param gradient defines the gradient to remove
  18560. * @returns the current particle system
  18561. */
  18562. removeSizeGradient(gradient: number): IParticleSystem;
  18563. /**
  18564. * Gets the current list of color gradients.
  18565. * You must use addColorGradient and removeColorGradient to udpate this list
  18566. * @returns the list of color gradients
  18567. */
  18568. getColorGradients(): Nullable<Array<ColorGradient>>;
  18569. /**
  18570. * Gets the current list of size gradients.
  18571. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18572. * @returns the list of size gradients
  18573. */
  18574. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18575. /**
  18576. * Gets the current list of angular speed gradients.
  18577. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18578. * @returns the list of angular speed gradients
  18579. */
  18580. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18581. /**
  18582. * Adds a new angular speed gradient
  18583. * @param gradient defines the gradient to use (between 0 and 1)
  18584. * @param factor defines the angular speed to affect to the specified gradient
  18585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18586. * @returns the current particle system
  18587. */
  18588. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18589. /**
  18590. * Remove a specific angular speed gradient
  18591. * @param gradient defines the gradient to remove
  18592. * @returns the current particle system
  18593. */
  18594. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18595. /**
  18596. * Gets the current list of velocity gradients.
  18597. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18598. * @returns the list of velocity gradients
  18599. */
  18600. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18601. /**
  18602. * Adds a new velocity gradient
  18603. * @param gradient defines the gradient to use (between 0 and 1)
  18604. * @param factor defines the velocity to affect to the specified gradient
  18605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18606. * @returns the current particle system
  18607. */
  18608. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18609. /**
  18610. * Remove a specific velocity gradient
  18611. * @param gradient defines the gradient to remove
  18612. * @returns the current particle system
  18613. */
  18614. removeVelocityGradient(gradient: number): IParticleSystem;
  18615. /**
  18616. * Gets the current list of limit velocity gradients.
  18617. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18618. * @returns the list of limit velocity gradients
  18619. */
  18620. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18621. /**
  18622. * Adds a new limit velocity gradient
  18623. * @param gradient defines the gradient to use (between 0 and 1)
  18624. * @param factor defines the limit velocity to affect to the specified gradient
  18625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18626. * @returns the current particle system
  18627. */
  18628. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18629. /**
  18630. * Remove a specific limit velocity gradient
  18631. * @param gradient defines the gradient to remove
  18632. * @returns the current particle system
  18633. */
  18634. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18635. /**
  18636. * Adds a new drag gradient
  18637. * @param gradient defines the gradient to use (between 0 and 1)
  18638. * @param factor defines the drag to affect to the specified gradient
  18639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18640. * @returns the current particle system
  18641. */
  18642. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18643. /**
  18644. * Remove a specific drag gradient
  18645. * @param gradient defines the gradient to remove
  18646. * @returns the current particle system
  18647. */
  18648. removeDragGradient(gradient: number): IParticleSystem;
  18649. /**
  18650. * Gets the current list of drag gradients.
  18651. * You must use addDragGradient and removeDragGradient to udpate this list
  18652. * @returns the list of drag gradients
  18653. */
  18654. getDragGradients(): Nullable<Array<FactorGradient>>;
  18655. /**
  18656. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18657. * @param gradient defines the gradient to use (between 0 and 1)
  18658. * @param factor defines the emit rate to affect to the specified gradient
  18659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18660. * @returns the current particle system
  18661. */
  18662. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18663. /**
  18664. * Remove a specific emit rate gradient
  18665. * @param gradient defines the gradient to remove
  18666. * @returns the current particle system
  18667. */
  18668. removeEmitRateGradient(gradient: number): IParticleSystem;
  18669. /**
  18670. * Gets the current list of emit rate gradients.
  18671. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18672. * @returns the list of emit rate gradients
  18673. */
  18674. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18675. /**
  18676. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18677. * @param gradient defines the gradient to use (between 0 and 1)
  18678. * @param factor defines the start size to affect to the specified gradient
  18679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18680. * @returns the current particle system
  18681. */
  18682. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18683. /**
  18684. * Remove a specific start size gradient
  18685. * @param gradient defines the gradient to remove
  18686. * @returns the current particle system
  18687. */
  18688. removeStartSizeGradient(gradient: number): IParticleSystem;
  18689. /**
  18690. * Gets the current list of start size gradients.
  18691. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18692. * @returns the list of start size gradients
  18693. */
  18694. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18695. /**
  18696. * Adds a new life time gradient
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param factor defines the life time factor to affect to the specified gradient
  18699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18700. * @returns the current particle system
  18701. */
  18702. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18703. /**
  18704. * Remove a specific life time gradient
  18705. * @param gradient defines the gradient to remove
  18706. * @returns the current particle system
  18707. */
  18708. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18709. /**
  18710. * Gets the current list of life time gradients.
  18711. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18712. * @returns the list of life time gradients
  18713. */
  18714. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18715. /**
  18716. * Gets the current list of color gradients.
  18717. * You must use addColorGradient and removeColorGradient to udpate this list
  18718. * @returns the list of color gradients
  18719. */
  18720. getColorGradients(): Nullable<Array<ColorGradient>>;
  18721. /**
  18722. * Adds a new ramp gradient used to remap particle colors
  18723. * @param gradient defines the gradient to use (between 0 and 1)
  18724. * @param color defines the color to affect to the specified gradient
  18725. * @returns the current particle system
  18726. */
  18727. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18728. /**
  18729. * Gets the current list of ramp gradients.
  18730. * You must use addRampGradient and removeRampGradient to udpate this list
  18731. * @returns the list of ramp gradients
  18732. */
  18733. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18734. /** Gets or sets a boolean indicating that ramp gradients must be used
  18735. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18736. */
  18737. useRampGradients: boolean;
  18738. /**
  18739. * Adds a new color remap gradient
  18740. * @param gradient defines the gradient to use (between 0 and 1)
  18741. * @param min defines the color remap minimal range
  18742. * @param max defines the color remap maximal range
  18743. * @returns the current particle system
  18744. */
  18745. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18746. /**
  18747. * Gets the current list of color remap gradients.
  18748. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18749. * @returns the list of color remap gradients
  18750. */
  18751. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18752. /**
  18753. * Adds a new alpha remap gradient
  18754. * @param gradient defines the gradient to use (between 0 and 1)
  18755. * @param min defines the alpha remap minimal range
  18756. * @param max defines the alpha remap maximal range
  18757. * @returns the current particle system
  18758. */
  18759. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18760. /**
  18761. * Gets the current list of alpha remap gradients.
  18762. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18763. * @returns the list of alpha remap gradients
  18764. */
  18765. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18766. /**
  18767. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18768. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18769. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18770. * @returns the emitter
  18771. */
  18772. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18773. /**
  18774. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18775. * @param radius The radius of the hemisphere to emit from
  18776. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18777. * @returns the emitter
  18778. */
  18779. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18780. /**
  18781. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18782. * @param radius The radius of the sphere to emit from
  18783. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18784. * @returns the emitter
  18785. */
  18786. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18787. /**
  18788. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18789. * @param radius The radius of the sphere to emit from
  18790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18792. * @returns the emitter
  18793. */
  18794. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18795. /**
  18796. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18797. * @param radius The radius of the emission cylinder
  18798. * @param height The height of the emission cylinder
  18799. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18800. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18801. * @returns the emitter
  18802. */
  18803. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18804. /**
  18805. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18806. * @param radius The radius of the cylinder to emit from
  18807. * @param height The height of the emission cylinder
  18808. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18811. * @returns the emitter
  18812. */
  18813. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18814. /**
  18815. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18816. * @param radius The radius of the cone to emit from
  18817. * @param angle The base angle of the cone
  18818. * @returns the emitter
  18819. */
  18820. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18821. /**
  18822. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18825. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18826. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18827. * @returns the emitter
  18828. */
  18829. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18830. /**
  18831. * Get hosting scene
  18832. * @returns the scene
  18833. */
  18834. getScene(): Scene;
  18835. }
  18836. }
  18837. declare module BABYLON {
  18838. /**
  18839. * Creates an instance based on a source mesh.
  18840. */
  18841. export class InstancedMesh extends AbstractMesh {
  18842. private _sourceMesh;
  18843. private _currentLOD;
  18844. /** @hidden */
  18845. _indexInSourceMeshInstanceArray: number;
  18846. constructor(name: string, source: Mesh);
  18847. /**
  18848. * Returns the string "InstancedMesh".
  18849. */
  18850. getClassName(): string;
  18851. /** Gets the list of lights affecting that mesh */
  18852. readonly lightSources: Light[];
  18853. _resyncLightSources(): void;
  18854. _resyncLighSource(light: Light): void;
  18855. _removeLightSource(light: Light, dispose: boolean): void;
  18856. /**
  18857. * If the source mesh receives shadows
  18858. */
  18859. readonly receiveShadows: boolean;
  18860. /**
  18861. * The material of the source mesh
  18862. */
  18863. readonly material: Nullable<Material>;
  18864. /**
  18865. * Visibility of the source mesh
  18866. */
  18867. readonly visibility: number;
  18868. /**
  18869. * Skeleton of the source mesh
  18870. */
  18871. readonly skeleton: Nullable<Skeleton>;
  18872. /**
  18873. * Rendering ground id of the source mesh
  18874. */
  18875. renderingGroupId: number;
  18876. /**
  18877. * Returns the total number of vertices (integer).
  18878. */
  18879. getTotalVertices(): number;
  18880. /**
  18881. * Returns a positive integer : the total number of indices in this mesh geometry.
  18882. * @returns the numner of indices or zero if the mesh has no geometry.
  18883. */
  18884. getTotalIndices(): number;
  18885. /**
  18886. * The source mesh of the instance
  18887. */
  18888. readonly sourceMesh: Mesh;
  18889. /**
  18890. * Is this node ready to be used/rendered
  18891. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18892. * @return {boolean} is it ready
  18893. */
  18894. isReady(completeCheck?: boolean): boolean;
  18895. /**
  18896. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18897. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18898. * @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.
  18899. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18900. */
  18901. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18902. /**
  18903. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18904. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18905. * The `data` are either a numeric array either a Float32Array.
  18906. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18907. * 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).
  18908. * Note that a new underlying VertexBuffer object is created each call.
  18909. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18910. *
  18911. * Possible `kind` values :
  18912. * - VertexBuffer.PositionKind
  18913. * - VertexBuffer.UVKind
  18914. * - VertexBuffer.UV2Kind
  18915. * - VertexBuffer.UV3Kind
  18916. * - VertexBuffer.UV4Kind
  18917. * - VertexBuffer.UV5Kind
  18918. * - VertexBuffer.UV6Kind
  18919. * - VertexBuffer.ColorKind
  18920. * - VertexBuffer.MatricesIndicesKind
  18921. * - VertexBuffer.MatricesIndicesExtraKind
  18922. * - VertexBuffer.MatricesWeightsKind
  18923. * - VertexBuffer.MatricesWeightsExtraKind
  18924. *
  18925. * Returns the Mesh.
  18926. */
  18927. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18928. /**
  18929. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18930. * If the mesh has no geometry, it is simply returned as it is.
  18931. * The `data` are either a numeric array either a Float32Array.
  18932. * No new underlying VertexBuffer object is created.
  18933. * 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.
  18934. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18935. *
  18936. * Possible `kind` values :
  18937. * - VertexBuffer.PositionKind
  18938. * - VertexBuffer.UVKind
  18939. * - VertexBuffer.UV2Kind
  18940. * - VertexBuffer.UV3Kind
  18941. * - VertexBuffer.UV4Kind
  18942. * - VertexBuffer.UV5Kind
  18943. * - VertexBuffer.UV6Kind
  18944. * - VertexBuffer.ColorKind
  18945. * - VertexBuffer.MatricesIndicesKind
  18946. * - VertexBuffer.MatricesIndicesExtraKind
  18947. * - VertexBuffer.MatricesWeightsKind
  18948. * - VertexBuffer.MatricesWeightsExtraKind
  18949. *
  18950. * Returns the Mesh.
  18951. */
  18952. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18953. /**
  18954. * Sets the mesh indices.
  18955. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18956. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18957. * This method creates a new index buffer each call.
  18958. * Returns the Mesh.
  18959. */
  18960. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18961. /**
  18962. * Boolean : True if the mesh owns the requested kind of data.
  18963. */
  18964. isVerticesDataPresent(kind: string): boolean;
  18965. /**
  18966. * Returns an array of indices (IndicesArray).
  18967. */
  18968. getIndices(): Nullable<IndicesArray>;
  18969. readonly _positions: Nullable<Vector3[]>;
  18970. /**
  18971. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18972. * This means the mesh underlying bounding box and sphere are recomputed.
  18973. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18974. * @returns the current mesh
  18975. */
  18976. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18977. /** @hidden */
  18978. _preActivate(): InstancedMesh;
  18979. /** @hidden */
  18980. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18981. /** @hidden */
  18982. _postActivate(): void;
  18983. getWorldMatrix(): Matrix;
  18984. readonly isAnInstance: boolean;
  18985. /**
  18986. * Returns the current associated LOD AbstractMesh.
  18987. */
  18988. getLOD(camera: Camera): AbstractMesh;
  18989. /** @hidden */
  18990. _syncSubMeshes(): InstancedMesh;
  18991. /** @hidden */
  18992. _generatePointsArray(): boolean;
  18993. /**
  18994. * Creates a new InstancedMesh from the current mesh.
  18995. * - name (string) : the cloned mesh name
  18996. * - newParent (optional Node) : the optional Node to parent the clone to.
  18997. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18998. *
  18999. * Returns the clone.
  19000. */
  19001. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19002. /**
  19003. * Disposes the InstancedMesh.
  19004. * Returns nothing.
  19005. */
  19006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19007. }
  19008. interface Mesh {
  19009. /**
  19010. * Register a custom buffer that will be instanced
  19011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19012. * @param kind defines the buffer kind
  19013. * @param stride defines the stride in floats
  19014. */
  19015. registerInstancedBuffer(kind: string, stride: number): void;
  19016. /** @hidden */
  19017. _userInstancedBuffersStorage: {
  19018. data: {
  19019. [key: string]: Float32Array;
  19020. };
  19021. sizes: {
  19022. [key: string]: number;
  19023. };
  19024. vertexBuffers: {
  19025. [key: string]: Nullable<VertexBuffer>;
  19026. };
  19027. strides: {
  19028. [key: string]: number;
  19029. };
  19030. };
  19031. }
  19032. interface AbstractMesh {
  19033. /**
  19034. * Object used to store instanced buffers defined by user
  19035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19036. */
  19037. instancedBuffers: {
  19038. [key: string]: any;
  19039. };
  19040. }
  19041. }
  19042. declare module BABYLON {
  19043. /**
  19044. * Defines the options associated with the creation of a shader material.
  19045. */
  19046. export interface IShaderMaterialOptions {
  19047. /**
  19048. * Does the material work in alpha blend mode
  19049. */
  19050. needAlphaBlending: boolean;
  19051. /**
  19052. * Does the material work in alpha test mode
  19053. */
  19054. needAlphaTesting: boolean;
  19055. /**
  19056. * The list of attribute names used in the shader
  19057. */
  19058. attributes: string[];
  19059. /**
  19060. * The list of unifrom names used in the shader
  19061. */
  19062. uniforms: string[];
  19063. /**
  19064. * The list of UBO names used in the shader
  19065. */
  19066. uniformBuffers: string[];
  19067. /**
  19068. * The list of sampler names used in the shader
  19069. */
  19070. samplers: string[];
  19071. /**
  19072. * The list of defines used in the shader
  19073. */
  19074. defines: string[];
  19075. }
  19076. /**
  19077. * 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.
  19078. *
  19079. * This returned material effects how the mesh will look based on the code in the shaders.
  19080. *
  19081. * @see http://doc.babylonjs.com/how_to/shader_material
  19082. */
  19083. export class ShaderMaterial extends Material {
  19084. private _shaderPath;
  19085. private _options;
  19086. private _textures;
  19087. private _textureArrays;
  19088. private _floats;
  19089. private _ints;
  19090. private _floatsArrays;
  19091. private _colors3;
  19092. private _colors3Arrays;
  19093. private _colors4;
  19094. private _colors4Arrays;
  19095. private _vectors2;
  19096. private _vectors3;
  19097. private _vectors4;
  19098. private _matrices;
  19099. private _matrices3x3;
  19100. private _matrices2x2;
  19101. private _vectors2Arrays;
  19102. private _vectors3Arrays;
  19103. private _vectors4Arrays;
  19104. private _cachedWorldViewMatrix;
  19105. private _cachedWorldViewProjectionMatrix;
  19106. private _renderId;
  19107. /**
  19108. * Instantiate a new shader material.
  19109. * 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.
  19110. * This returned material effects how the mesh will look based on the code in the shaders.
  19111. * @see http://doc.babylonjs.com/how_to/shader_material
  19112. * @param name Define the name of the material in the scene
  19113. * @param scene Define the scene the material belongs to
  19114. * @param shaderPath Defines the route to the shader code in one of three ways:
  19115. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19116. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19117. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19118. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19119. * @param options Define the options used to create the shader
  19120. */
  19121. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19122. /**
  19123. * Gets the options used to compile the shader.
  19124. * They can be modified to trigger a new compilation
  19125. */
  19126. readonly options: IShaderMaterialOptions;
  19127. /**
  19128. * Gets the current class name of the material e.g. "ShaderMaterial"
  19129. * Mainly use in serialization.
  19130. * @returns the class name
  19131. */
  19132. getClassName(): string;
  19133. /**
  19134. * Specifies if the material will require alpha blending
  19135. * @returns a boolean specifying if alpha blending is needed
  19136. */
  19137. needAlphaBlending(): boolean;
  19138. /**
  19139. * Specifies if this material should be rendered in alpha test mode
  19140. * @returns a boolean specifying if an alpha test is needed.
  19141. */
  19142. needAlphaTesting(): boolean;
  19143. private _checkUniform;
  19144. /**
  19145. * Set a texture in the shader.
  19146. * @param name Define the name of the uniform samplers as defined in the shader
  19147. * @param texture Define the texture to bind to this sampler
  19148. * @return the material itself allowing "fluent" like uniform updates
  19149. */
  19150. setTexture(name: string, texture: Texture): ShaderMaterial;
  19151. /**
  19152. * Set a texture array in the shader.
  19153. * @param name Define the name of the uniform sampler array as defined in the shader
  19154. * @param textures Define the list of textures to bind to this sampler
  19155. * @return the material itself allowing "fluent" like uniform updates
  19156. */
  19157. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19158. /**
  19159. * Set a float in the shader.
  19160. * @param name Define the name of the uniform as defined in the shader
  19161. * @param value Define the value to give to the uniform
  19162. * @return the material itself allowing "fluent" like uniform updates
  19163. */
  19164. setFloat(name: string, value: number): ShaderMaterial;
  19165. /**
  19166. * Set a int in the shader.
  19167. * @param name Define the name of the uniform as defined in the shader
  19168. * @param value Define the value to give to the uniform
  19169. * @return the material itself allowing "fluent" like uniform updates
  19170. */
  19171. setInt(name: string, value: number): ShaderMaterial;
  19172. /**
  19173. * Set an array of floats in the shader.
  19174. * @param name Define the name of the uniform as defined in the shader
  19175. * @param value Define the value to give to the uniform
  19176. * @return the material itself allowing "fluent" like uniform updates
  19177. */
  19178. setFloats(name: string, value: number[]): ShaderMaterial;
  19179. /**
  19180. * Set a vec3 in the shader from a Color3.
  19181. * @param name Define the name of the uniform as defined in the shader
  19182. * @param value Define the value to give to the uniform
  19183. * @return the material itself allowing "fluent" like uniform updates
  19184. */
  19185. setColor3(name: string, value: Color3): ShaderMaterial;
  19186. /**
  19187. * Set a vec3 array in the shader from a Color3 array.
  19188. * @param name Define the name of the uniform as defined in the shader
  19189. * @param value Define the value to give to the uniform
  19190. * @return the material itself allowing "fluent" like uniform updates
  19191. */
  19192. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19193. /**
  19194. * Set a vec4 in the shader from a Color4.
  19195. * @param name Define the name of the uniform as defined in the shader
  19196. * @param value Define the value to give to the uniform
  19197. * @return the material itself allowing "fluent" like uniform updates
  19198. */
  19199. setColor4(name: string, value: Color4): ShaderMaterial;
  19200. /**
  19201. * Set a vec4 array in the shader from a Color4 array.
  19202. * @param name Define the name of the uniform as defined in the shader
  19203. * @param value Define the value to give to the uniform
  19204. * @return the material itself allowing "fluent" like uniform updates
  19205. */
  19206. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19207. /**
  19208. * Set a vec2 in the shader from a Vector2.
  19209. * @param name Define the name of the uniform as defined in the shader
  19210. * @param value Define the value to give to the uniform
  19211. * @return the material itself allowing "fluent" like uniform updates
  19212. */
  19213. setVector2(name: string, value: Vector2): ShaderMaterial;
  19214. /**
  19215. * Set a vec3 in the shader from a Vector3.
  19216. * @param name Define the name of the uniform as defined in the shader
  19217. * @param value Define the value to give to the uniform
  19218. * @return the material itself allowing "fluent" like uniform updates
  19219. */
  19220. setVector3(name: string, value: Vector3): ShaderMaterial;
  19221. /**
  19222. * Set a vec4 in the shader from a Vector4.
  19223. * @param name Define the name of the uniform as defined in the shader
  19224. * @param value Define the value to give to the uniform
  19225. * @return the material itself allowing "fluent" like uniform updates
  19226. */
  19227. setVector4(name: string, value: Vector4): ShaderMaterial;
  19228. /**
  19229. * Set a mat4 in the shader from a Matrix.
  19230. * @param name Define the name of the uniform as defined in the shader
  19231. * @param value Define the value to give to the uniform
  19232. * @return the material itself allowing "fluent" like uniform updates
  19233. */
  19234. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19235. /**
  19236. * Set a mat3 in the shader from a Float32Array.
  19237. * @param name Define the name of the uniform as defined in the shader
  19238. * @param value Define the value to give to the uniform
  19239. * @return the material itself allowing "fluent" like uniform updates
  19240. */
  19241. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19242. /**
  19243. * Set a mat2 in the shader from a Float32Array.
  19244. * @param name Define the name of the uniform as defined in the shader
  19245. * @param value Define the value to give to the uniform
  19246. * @return the material itself allowing "fluent" like uniform updates
  19247. */
  19248. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19249. /**
  19250. * Set a vec2 array in the shader from a number array.
  19251. * @param name Define the name of the uniform as defined in the shader
  19252. * @param value Define the value to give to the uniform
  19253. * @return the material itself allowing "fluent" like uniform updates
  19254. */
  19255. setArray2(name: string, value: number[]): ShaderMaterial;
  19256. /**
  19257. * Set a vec3 array in the shader from a number array.
  19258. * @param name Define the name of the uniform as defined in the shader
  19259. * @param value Define the value to give to the uniform
  19260. * @return the material itself allowing "fluent" like uniform updates
  19261. */
  19262. setArray3(name: string, value: number[]): ShaderMaterial;
  19263. /**
  19264. * Set a vec4 array in the shader from a number array.
  19265. * @param name Define the name of the uniform as defined in the shader
  19266. * @param value Define the value to give to the uniform
  19267. * @return the material itself allowing "fluent" like uniform updates
  19268. */
  19269. setArray4(name: string, value: number[]): ShaderMaterial;
  19270. private _checkCache;
  19271. /**
  19272. * Specifies that the submesh is ready to be used
  19273. * @param mesh defines the mesh to check
  19274. * @param subMesh defines which submesh to check
  19275. * @param useInstances specifies that instances should be used
  19276. * @returns a boolean indicating that the submesh is ready or not
  19277. */
  19278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19279. /**
  19280. * Checks if the material is ready to render the requested mesh
  19281. * @param mesh Define the mesh to render
  19282. * @param useInstances Define whether or not the material is used with instances
  19283. * @returns true if ready, otherwise false
  19284. */
  19285. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19286. /**
  19287. * Binds the world matrix to the material
  19288. * @param world defines the world transformation matrix
  19289. */
  19290. bindOnlyWorldMatrix(world: Matrix): void;
  19291. /**
  19292. * Binds the material to the mesh
  19293. * @param world defines the world transformation matrix
  19294. * @param mesh defines the mesh to bind the material to
  19295. */
  19296. bind(world: Matrix, mesh?: Mesh): void;
  19297. /**
  19298. * Gets the active textures from the material
  19299. * @returns an array of textures
  19300. */
  19301. getActiveTextures(): BaseTexture[];
  19302. /**
  19303. * Specifies if the material uses a texture
  19304. * @param texture defines the texture to check against the material
  19305. * @returns a boolean specifying if the material uses the texture
  19306. */
  19307. hasTexture(texture: BaseTexture): boolean;
  19308. /**
  19309. * Makes a duplicate of the material, and gives it a new name
  19310. * @param name defines the new name for the duplicated material
  19311. * @returns the cloned material
  19312. */
  19313. clone(name: string): ShaderMaterial;
  19314. /**
  19315. * Disposes the material
  19316. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19317. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19318. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19319. */
  19320. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19321. /**
  19322. * Serializes this material in a JSON representation
  19323. * @returns the serialized material object
  19324. */
  19325. serialize(): any;
  19326. /**
  19327. * Creates a shader material from parsed shader material data
  19328. * @param source defines the JSON represnetation of the material
  19329. * @param scene defines the hosting scene
  19330. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19331. * @returns a new material
  19332. */
  19333. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19334. }
  19335. }
  19336. declare module BABYLON {
  19337. /** @hidden */
  19338. export var colorPixelShader: {
  19339. name: string;
  19340. shader: string;
  19341. };
  19342. }
  19343. declare module BABYLON {
  19344. /** @hidden */
  19345. export var colorVertexShader: {
  19346. name: string;
  19347. shader: string;
  19348. };
  19349. }
  19350. declare module BABYLON {
  19351. /**
  19352. * Line mesh
  19353. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19354. */
  19355. export class LinesMesh extends Mesh {
  19356. /**
  19357. * If vertex color should be applied to the mesh
  19358. */
  19359. readonly useVertexColor?: boolean | undefined;
  19360. /**
  19361. * If vertex alpha should be applied to the mesh
  19362. */
  19363. readonly useVertexAlpha?: boolean | undefined;
  19364. /**
  19365. * Color of the line (Default: White)
  19366. */
  19367. color: Color3;
  19368. /**
  19369. * Alpha of the line (Default: 1)
  19370. */
  19371. alpha: number;
  19372. /**
  19373. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19374. * This margin is expressed in world space coordinates, so its value may vary.
  19375. * Default value is 0.1
  19376. */
  19377. intersectionThreshold: number;
  19378. private _colorShader;
  19379. private color4;
  19380. /**
  19381. * Creates a new LinesMesh
  19382. * @param name defines the name
  19383. * @param scene defines the hosting scene
  19384. * @param parent defines the parent mesh if any
  19385. * @param source defines the optional source LinesMesh used to clone data from
  19386. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19387. * When false, achieved by calling a clone(), also passing False.
  19388. * This will make creation of children, recursive.
  19389. * @param useVertexColor defines if this LinesMesh supports vertex color
  19390. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19391. */
  19392. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19393. /**
  19394. * If vertex color should be applied to the mesh
  19395. */
  19396. useVertexColor?: boolean | undefined,
  19397. /**
  19398. * If vertex alpha should be applied to the mesh
  19399. */
  19400. useVertexAlpha?: boolean | undefined);
  19401. private _addClipPlaneDefine;
  19402. private _removeClipPlaneDefine;
  19403. isReady(): boolean;
  19404. /**
  19405. * Returns the string "LineMesh"
  19406. */
  19407. getClassName(): string;
  19408. /**
  19409. * @hidden
  19410. */
  19411. /**
  19412. * @hidden
  19413. */
  19414. material: Material;
  19415. /**
  19416. * @hidden
  19417. */
  19418. readonly checkCollisions: boolean;
  19419. /** @hidden */
  19420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19421. /** @hidden */
  19422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19423. /**
  19424. * Disposes of the line mesh
  19425. * @param doNotRecurse If children should be disposed
  19426. */
  19427. dispose(doNotRecurse?: boolean): void;
  19428. /**
  19429. * Returns a new LineMesh object cloned from the current one.
  19430. */
  19431. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19432. /**
  19433. * Creates a new InstancedLinesMesh object from the mesh model.
  19434. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19435. * @param name defines the name of the new instance
  19436. * @returns a new InstancedLinesMesh
  19437. */
  19438. createInstance(name: string): InstancedLinesMesh;
  19439. }
  19440. /**
  19441. * Creates an instance based on a source LinesMesh
  19442. */
  19443. export class InstancedLinesMesh extends InstancedMesh {
  19444. /**
  19445. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19446. * This margin is expressed in world space coordinates, so its value may vary.
  19447. * Initilized with the intersectionThreshold value of the source LinesMesh
  19448. */
  19449. intersectionThreshold: number;
  19450. constructor(name: string, source: LinesMesh);
  19451. /**
  19452. * Returns the string "InstancedLinesMesh".
  19453. */
  19454. getClassName(): string;
  19455. }
  19456. }
  19457. declare module BABYLON {
  19458. /** @hidden */
  19459. export var linePixelShader: {
  19460. name: string;
  19461. shader: string;
  19462. };
  19463. }
  19464. declare module BABYLON {
  19465. /** @hidden */
  19466. export var lineVertexShader: {
  19467. name: string;
  19468. shader: string;
  19469. };
  19470. }
  19471. declare module BABYLON {
  19472. interface AbstractMesh {
  19473. /**
  19474. * Gets the edgesRenderer associated with the mesh
  19475. */
  19476. edgesRenderer: Nullable<EdgesRenderer>;
  19477. }
  19478. interface LinesMesh {
  19479. /**
  19480. * Enables the edge rendering mode on the mesh.
  19481. * This mode makes the mesh edges visible
  19482. * @param epsilon defines the maximal distance between two angles to detect a face
  19483. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19484. * @returns the currentAbstractMesh
  19485. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19486. */
  19487. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19488. }
  19489. interface InstancedLinesMesh {
  19490. /**
  19491. * Enables the edge rendering mode on the mesh.
  19492. * This mode makes the mesh edges visible
  19493. * @param epsilon defines the maximal distance between two angles to detect a face
  19494. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19495. * @returns the current InstancedLinesMesh
  19496. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19497. */
  19498. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19499. }
  19500. /**
  19501. * Defines the minimum contract an Edges renderer should follow.
  19502. */
  19503. export interface IEdgesRenderer extends IDisposable {
  19504. /**
  19505. * Gets or sets a boolean indicating if the edgesRenderer is active
  19506. */
  19507. isEnabled: boolean;
  19508. /**
  19509. * Renders the edges of the attached mesh,
  19510. */
  19511. render(): void;
  19512. /**
  19513. * Checks wether or not the edges renderer is ready to render.
  19514. * @return true if ready, otherwise false.
  19515. */
  19516. isReady(): boolean;
  19517. }
  19518. /**
  19519. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19520. */
  19521. export class EdgesRenderer implements IEdgesRenderer {
  19522. /**
  19523. * Define the size of the edges with an orthographic camera
  19524. */
  19525. edgesWidthScalerForOrthographic: number;
  19526. /**
  19527. * Define the size of the edges with a perspective camera
  19528. */
  19529. edgesWidthScalerForPerspective: number;
  19530. protected _source: AbstractMesh;
  19531. protected _linesPositions: number[];
  19532. protected _linesNormals: number[];
  19533. protected _linesIndices: number[];
  19534. protected _epsilon: number;
  19535. protected _indicesCount: number;
  19536. protected _lineShader: ShaderMaterial;
  19537. protected _ib: DataBuffer;
  19538. protected _buffers: {
  19539. [key: string]: Nullable<VertexBuffer>;
  19540. };
  19541. protected _checkVerticesInsteadOfIndices: boolean;
  19542. private _meshRebuildObserver;
  19543. private _meshDisposeObserver;
  19544. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19545. isEnabled: boolean;
  19546. /**
  19547. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19548. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19549. * @param source Mesh used to create edges
  19550. * @param epsilon sum of angles in adjacency to check for edge
  19551. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19552. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19553. */
  19554. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19555. protected _prepareRessources(): void;
  19556. /** @hidden */
  19557. _rebuild(): void;
  19558. /**
  19559. * Releases the required resources for the edges renderer
  19560. */
  19561. dispose(): void;
  19562. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19563. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19564. /**
  19565. * Checks if the pair of p0 and p1 is en edge
  19566. * @param faceIndex
  19567. * @param edge
  19568. * @param faceNormals
  19569. * @param p0
  19570. * @param p1
  19571. * @private
  19572. */
  19573. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19574. /**
  19575. * push line into the position, normal and index buffer
  19576. * @protected
  19577. */
  19578. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19579. /**
  19580. * Generates lines edges from adjacencjes
  19581. * @private
  19582. */
  19583. _generateEdgesLines(): void;
  19584. /**
  19585. * Checks wether or not the edges renderer is ready to render.
  19586. * @return true if ready, otherwise false.
  19587. */
  19588. isReady(): boolean;
  19589. /**
  19590. * Renders the edges of the attached mesh,
  19591. */
  19592. render(): void;
  19593. }
  19594. /**
  19595. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19596. */
  19597. export class LineEdgesRenderer extends EdgesRenderer {
  19598. /**
  19599. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19600. * @param source LineMesh used to generate edges
  19601. * @param epsilon not important (specified angle for edge detection)
  19602. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19603. */
  19604. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19605. /**
  19606. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19607. */
  19608. _generateEdgesLines(): void;
  19609. }
  19610. }
  19611. declare module BABYLON {
  19612. /**
  19613. * This represents the object necessary to create a rendering group.
  19614. * This is exclusively used and created by the rendering manager.
  19615. * To modify the behavior, you use the available helpers in your scene or meshes.
  19616. * @hidden
  19617. */
  19618. export class RenderingGroup {
  19619. index: number;
  19620. private static _zeroVector;
  19621. private _scene;
  19622. private _opaqueSubMeshes;
  19623. private _transparentSubMeshes;
  19624. private _alphaTestSubMeshes;
  19625. private _depthOnlySubMeshes;
  19626. private _particleSystems;
  19627. private _spriteManagers;
  19628. private _opaqueSortCompareFn;
  19629. private _alphaTestSortCompareFn;
  19630. private _transparentSortCompareFn;
  19631. private _renderOpaque;
  19632. private _renderAlphaTest;
  19633. private _renderTransparent;
  19634. /** @hidden */
  19635. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19636. onBeforeTransparentRendering: () => void;
  19637. /**
  19638. * Set the opaque sort comparison function.
  19639. * If null the sub meshes will be render in the order they were created
  19640. */
  19641. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19642. /**
  19643. * Set the alpha test sort comparison function.
  19644. * If null the sub meshes will be render in the order they were created
  19645. */
  19646. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19647. /**
  19648. * Set the transparent sort comparison function.
  19649. * If null the sub meshes will be render in the order they were created
  19650. */
  19651. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19652. /**
  19653. * Creates a new rendering group.
  19654. * @param index The rendering group index
  19655. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19656. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19657. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19658. */
  19659. 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>);
  19660. /**
  19661. * Render all the sub meshes contained in the group.
  19662. * @param customRenderFunction Used to override the default render behaviour of the group.
  19663. * @returns true if rendered some submeshes.
  19664. */
  19665. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19666. /**
  19667. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19668. * @param subMeshes The submeshes to render
  19669. */
  19670. private renderOpaqueSorted;
  19671. /**
  19672. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19673. * @param subMeshes The submeshes to render
  19674. */
  19675. private renderAlphaTestSorted;
  19676. /**
  19677. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19678. * @param subMeshes The submeshes to render
  19679. */
  19680. private renderTransparentSorted;
  19681. /**
  19682. * Renders the submeshes in a specified order.
  19683. * @param subMeshes The submeshes to sort before render
  19684. * @param sortCompareFn The comparison function use to sort
  19685. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19686. * @param transparent Specifies to activate blending if true
  19687. */
  19688. private static renderSorted;
  19689. /**
  19690. * Renders the submeshes in the order they were dispatched (no sort applied).
  19691. * @param subMeshes The submeshes to render
  19692. */
  19693. private static renderUnsorted;
  19694. /**
  19695. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19696. * are rendered back to front if in the same alpha index.
  19697. *
  19698. * @param a The first submesh
  19699. * @param b The second submesh
  19700. * @returns The result of the comparison
  19701. */
  19702. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19703. /**
  19704. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19705. * are rendered back to front.
  19706. *
  19707. * @param a The first submesh
  19708. * @param b The second submesh
  19709. * @returns The result of the comparison
  19710. */
  19711. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19712. /**
  19713. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19714. * are rendered front to back (prevent overdraw).
  19715. *
  19716. * @param a The first submesh
  19717. * @param b The second submesh
  19718. * @returns The result of the comparison
  19719. */
  19720. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19721. /**
  19722. * Resets the different lists of submeshes to prepare a new frame.
  19723. */
  19724. prepare(): void;
  19725. dispose(): void;
  19726. /**
  19727. * Inserts the submesh in its correct queue depending on its material.
  19728. * @param subMesh The submesh to dispatch
  19729. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19730. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19731. */
  19732. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19733. dispatchSprites(spriteManager: ISpriteManager): void;
  19734. dispatchParticles(particleSystem: IParticleSystem): void;
  19735. private _renderParticles;
  19736. private _renderSprites;
  19737. }
  19738. }
  19739. declare module BABYLON {
  19740. /**
  19741. * Interface describing the different options available in the rendering manager
  19742. * regarding Auto Clear between groups.
  19743. */
  19744. export interface IRenderingManagerAutoClearSetup {
  19745. /**
  19746. * Defines whether or not autoclear is enable.
  19747. */
  19748. autoClear: boolean;
  19749. /**
  19750. * Defines whether or not to autoclear the depth buffer.
  19751. */
  19752. depth: boolean;
  19753. /**
  19754. * Defines whether or not to autoclear the stencil buffer.
  19755. */
  19756. stencil: boolean;
  19757. }
  19758. /**
  19759. * This class is used by the onRenderingGroupObservable
  19760. */
  19761. export class RenderingGroupInfo {
  19762. /**
  19763. * The Scene that being rendered
  19764. */
  19765. scene: Scene;
  19766. /**
  19767. * The camera currently used for the rendering pass
  19768. */
  19769. camera: Nullable<Camera>;
  19770. /**
  19771. * The ID of the renderingGroup being processed
  19772. */
  19773. renderingGroupId: number;
  19774. }
  19775. /**
  19776. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19777. * It is enable to manage the different groups as well as the different necessary sort functions.
  19778. * This should not be used directly aside of the few static configurations
  19779. */
  19780. export class RenderingManager {
  19781. /**
  19782. * The max id used for rendering groups (not included)
  19783. */
  19784. static MAX_RENDERINGGROUPS: number;
  19785. /**
  19786. * The min id used for rendering groups (included)
  19787. */
  19788. static MIN_RENDERINGGROUPS: number;
  19789. /**
  19790. * Used to globally prevent autoclearing scenes.
  19791. */
  19792. static AUTOCLEAR: boolean;
  19793. /**
  19794. * @hidden
  19795. */
  19796. _useSceneAutoClearSetup: boolean;
  19797. private _scene;
  19798. private _renderingGroups;
  19799. private _depthStencilBufferAlreadyCleaned;
  19800. private _autoClearDepthStencil;
  19801. private _customOpaqueSortCompareFn;
  19802. private _customAlphaTestSortCompareFn;
  19803. private _customTransparentSortCompareFn;
  19804. private _renderingGroupInfo;
  19805. /**
  19806. * Instantiates a new rendering group for a particular scene
  19807. * @param scene Defines the scene the groups belongs to
  19808. */
  19809. constructor(scene: Scene);
  19810. private _clearDepthStencilBuffer;
  19811. /**
  19812. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19813. * @hidden
  19814. */
  19815. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19816. /**
  19817. * Resets the different information of the group to prepare a new frame
  19818. * @hidden
  19819. */
  19820. reset(): void;
  19821. /**
  19822. * Dispose and release the group and its associated resources.
  19823. * @hidden
  19824. */
  19825. dispose(): void;
  19826. /**
  19827. * Clear the info related to rendering groups preventing retention points during dispose.
  19828. */
  19829. freeRenderingGroups(): void;
  19830. private _prepareRenderingGroup;
  19831. /**
  19832. * Add a sprite manager to the rendering manager in order to render it this frame.
  19833. * @param spriteManager Define the sprite manager to render
  19834. */
  19835. dispatchSprites(spriteManager: ISpriteManager): void;
  19836. /**
  19837. * Add a particle system to the rendering manager in order to render it this frame.
  19838. * @param particleSystem Define the particle system to render
  19839. */
  19840. dispatchParticles(particleSystem: IParticleSystem): void;
  19841. /**
  19842. * Add a submesh to the manager in order to render it this frame
  19843. * @param subMesh The submesh to dispatch
  19844. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19845. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19846. */
  19847. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19848. /**
  19849. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19850. * This allowed control for front to back rendering or reversly depending of the special needs.
  19851. *
  19852. * @param renderingGroupId The rendering group id corresponding to its index
  19853. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19854. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19855. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19856. */
  19857. 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;
  19858. /**
  19859. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19860. *
  19861. * @param renderingGroupId The rendering group id corresponding to its index
  19862. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19863. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19864. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19865. */
  19866. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19867. /**
  19868. * Gets the current auto clear configuration for one rendering group of the rendering
  19869. * manager.
  19870. * @param index the rendering group index to get the information for
  19871. * @returns The auto clear setup for the requested rendering group
  19872. */
  19873. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19874. }
  19875. }
  19876. declare module BABYLON {
  19877. /**
  19878. * This Helps creating a texture that will be created from a camera in your scene.
  19879. * It is basically a dynamic texture that could be used to create special effects for instance.
  19880. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19881. */
  19882. export class RenderTargetTexture extends Texture {
  19883. isCube: boolean;
  19884. /**
  19885. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19886. */
  19887. static readonly REFRESHRATE_RENDER_ONCE: number;
  19888. /**
  19889. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19890. */
  19891. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19892. /**
  19893. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19894. * the central point of your effect and can save a lot of performances.
  19895. */
  19896. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19897. /**
  19898. * Use this predicate to dynamically define the list of mesh you want to render.
  19899. * If set, the renderList property will be overwritten.
  19900. */
  19901. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19902. private _renderList;
  19903. /**
  19904. * Use this list to define the list of mesh you want to render.
  19905. */
  19906. renderList: Nullable<Array<AbstractMesh>>;
  19907. private _hookArray;
  19908. /**
  19909. * Define if particles should be rendered in your texture.
  19910. */
  19911. renderParticles: boolean;
  19912. /**
  19913. * Define if sprites should be rendered in your texture.
  19914. */
  19915. renderSprites: boolean;
  19916. /**
  19917. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19918. */
  19919. coordinatesMode: number;
  19920. /**
  19921. * Define the camera used to render the texture.
  19922. */
  19923. activeCamera: Nullable<Camera>;
  19924. /**
  19925. * Override the render function of the texture with your own one.
  19926. */
  19927. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19928. /**
  19929. * Define if camera post processes should be use while rendering the texture.
  19930. */
  19931. useCameraPostProcesses: boolean;
  19932. /**
  19933. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19934. */
  19935. ignoreCameraViewport: boolean;
  19936. private _postProcessManager;
  19937. private _postProcesses;
  19938. private _resizeObserver;
  19939. /**
  19940. * An event triggered when the texture is unbind.
  19941. */
  19942. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19943. /**
  19944. * An event triggered when the texture is unbind.
  19945. */
  19946. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19947. private _onAfterUnbindObserver;
  19948. /**
  19949. * Set a after unbind callback in the texture.
  19950. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19951. */
  19952. onAfterUnbind: () => void;
  19953. /**
  19954. * An event triggered before rendering the texture
  19955. */
  19956. onBeforeRenderObservable: Observable<number>;
  19957. private _onBeforeRenderObserver;
  19958. /**
  19959. * Set a before render callback in the texture.
  19960. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19961. */
  19962. onBeforeRender: (faceIndex: number) => void;
  19963. /**
  19964. * An event triggered after rendering the texture
  19965. */
  19966. onAfterRenderObservable: Observable<number>;
  19967. private _onAfterRenderObserver;
  19968. /**
  19969. * Set a after render callback in the texture.
  19970. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19971. */
  19972. onAfterRender: (faceIndex: number) => void;
  19973. /**
  19974. * An event triggered after the texture clear
  19975. */
  19976. onClearObservable: Observable<Engine>;
  19977. private _onClearObserver;
  19978. /**
  19979. * Set a clear callback in the texture.
  19980. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19981. */
  19982. onClear: (Engine: Engine) => void;
  19983. /**
  19984. * An event triggered when the texture is resized.
  19985. */
  19986. onResizeObservable: Observable<RenderTargetTexture>;
  19987. /**
  19988. * Define the clear color of the Render Target if it should be different from the scene.
  19989. */
  19990. clearColor: Color4;
  19991. protected _size: number | {
  19992. width: number;
  19993. height: number;
  19994. };
  19995. protected _initialSizeParameter: number | {
  19996. width: number;
  19997. height: number;
  19998. } | {
  19999. ratio: number;
  20000. };
  20001. protected _sizeRatio: Nullable<number>;
  20002. /** @hidden */
  20003. _generateMipMaps: boolean;
  20004. protected _renderingManager: RenderingManager;
  20005. /** @hidden */
  20006. _waitingRenderList: string[];
  20007. protected _doNotChangeAspectRatio: boolean;
  20008. protected _currentRefreshId: number;
  20009. protected _refreshRate: number;
  20010. protected _textureMatrix: Matrix;
  20011. protected _samples: number;
  20012. protected _renderTargetOptions: RenderTargetCreationOptions;
  20013. /**
  20014. * Gets render target creation options that were used.
  20015. */
  20016. readonly renderTargetOptions: RenderTargetCreationOptions;
  20017. protected _engine: Engine;
  20018. protected _onRatioRescale(): void;
  20019. /**
  20020. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20021. * It must define where the camera used to render the texture is set
  20022. */
  20023. boundingBoxPosition: Vector3;
  20024. private _boundingBoxSize;
  20025. /**
  20026. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20027. * When defined, the cubemap will switch to local mode
  20028. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20029. * @example https://www.babylonjs-playground.com/#RNASML
  20030. */
  20031. boundingBoxSize: Vector3;
  20032. /**
  20033. * In case the RTT has been created with a depth texture, get the associated
  20034. * depth texture.
  20035. * Otherwise, return null.
  20036. */
  20037. depthStencilTexture: Nullable<InternalTexture>;
  20038. /**
  20039. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20040. * or used a shadow, depth texture...
  20041. * @param name The friendly name of the texture
  20042. * @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)
  20043. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20044. * @param generateMipMaps True if mip maps need to be generated after render.
  20045. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20046. * @param type The type of the buffer in the RTT (int, half float, float...)
  20047. * @param isCube True if a cube texture needs to be created
  20048. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20049. * @param generateDepthBuffer True to generate a depth buffer
  20050. * @param generateStencilBuffer True to generate a stencil buffer
  20051. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20052. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20053. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20054. */
  20055. constructor(name: string, size: number | {
  20056. width: number;
  20057. height: number;
  20058. } | {
  20059. ratio: number;
  20060. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20061. /**
  20062. * Creates a depth stencil texture.
  20063. * This is only available in WebGL 2 or with the depth texture extension available.
  20064. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20065. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20066. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20067. */
  20068. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20069. private _processSizeParameter;
  20070. /**
  20071. * Define the number of samples to use in case of MSAA.
  20072. * It defaults to one meaning no MSAA has been enabled.
  20073. */
  20074. samples: number;
  20075. /**
  20076. * Resets the refresh counter of the texture and start bak from scratch.
  20077. * Could be useful to regenerate the texture if it is setup to render only once.
  20078. */
  20079. resetRefreshCounter(): void;
  20080. /**
  20081. * Define the refresh rate of the texture or the rendering frequency.
  20082. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20083. */
  20084. refreshRate: number;
  20085. /**
  20086. * Adds a post process to the render target rendering passes.
  20087. * @param postProcess define the post process to add
  20088. */
  20089. addPostProcess(postProcess: PostProcess): void;
  20090. /**
  20091. * Clear all the post processes attached to the render target
  20092. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20093. */
  20094. clearPostProcesses(dispose?: boolean): void;
  20095. /**
  20096. * Remove one of the post process from the list of attached post processes to the texture
  20097. * @param postProcess define the post process to remove from the list
  20098. */
  20099. removePostProcess(postProcess: PostProcess): void;
  20100. /** @hidden */
  20101. _shouldRender(): boolean;
  20102. /**
  20103. * Gets the actual render size of the texture.
  20104. * @returns the width of the render size
  20105. */
  20106. getRenderSize(): number;
  20107. /**
  20108. * Gets the actual render width of the texture.
  20109. * @returns the width of the render size
  20110. */
  20111. getRenderWidth(): number;
  20112. /**
  20113. * Gets the actual render height of the texture.
  20114. * @returns the height of the render size
  20115. */
  20116. getRenderHeight(): number;
  20117. /**
  20118. * Get if the texture can be rescaled or not.
  20119. */
  20120. readonly canRescale: boolean;
  20121. /**
  20122. * Resize the texture using a ratio.
  20123. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20124. */
  20125. scale(ratio: number): void;
  20126. /**
  20127. * Get the texture reflection matrix used to rotate/transform the reflection.
  20128. * @returns the reflection matrix
  20129. */
  20130. getReflectionTextureMatrix(): Matrix;
  20131. /**
  20132. * Resize the texture to a new desired size.
  20133. * Be carrefull as it will recreate all the data in the new texture.
  20134. * @param size Define the new size. It can be:
  20135. * - a number for squared texture,
  20136. * - an object containing { width: number, height: number }
  20137. * - or an object containing a ratio { ratio: number }
  20138. */
  20139. resize(size: number | {
  20140. width: number;
  20141. height: number;
  20142. } | {
  20143. ratio: number;
  20144. }): void;
  20145. /**
  20146. * Renders all the objects from the render list into the texture.
  20147. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20148. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20149. */
  20150. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20151. private _bestReflectionRenderTargetDimension;
  20152. /**
  20153. * @hidden
  20154. * @param faceIndex face index to bind to if this is a cubetexture
  20155. */
  20156. _bindFrameBuffer(faceIndex?: number): void;
  20157. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20158. private renderToTarget;
  20159. /**
  20160. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20161. * This allowed control for front to back rendering or reversly depending of the special needs.
  20162. *
  20163. * @param renderingGroupId The rendering group id corresponding to its index
  20164. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20165. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20166. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20167. */
  20168. 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;
  20169. /**
  20170. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20171. *
  20172. * @param renderingGroupId The rendering group id corresponding to its index
  20173. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20174. */
  20175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20176. /**
  20177. * Clones the texture.
  20178. * @returns the cloned texture
  20179. */
  20180. clone(): RenderTargetTexture;
  20181. /**
  20182. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20183. * @returns The JSON representation of the texture
  20184. */
  20185. serialize(): any;
  20186. /**
  20187. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20188. */
  20189. disposeFramebufferObjects(): void;
  20190. /**
  20191. * Dispose the texture and release its associated resources.
  20192. */
  20193. dispose(): void;
  20194. /** @hidden */
  20195. _rebuild(): void;
  20196. /**
  20197. * Clear the info related to rendering groups preventing retention point in material dispose.
  20198. */
  20199. freeRenderingGroups(): void;
  20200. /**
  20201. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20202. * @returns the view count
  20203. */
  20204. getViewCount(): number;
  20205. }
  20206. }
  20207. declare module BABYLON {
  20208. /**
  20209. * Options for compiling materials.
  20210. */
  20211. export interface IMaterialCompilationOptions {
  20212. /**
  20213. * Defines whether clip planes are enabled.
  20214. */
  20215. clipPlane: boolean;
  20216. /**
  20217. * Defines whether instances are enabled.
  20218. */
  20219. useInstances: boolean;
  20220. }
  20221. /**
  20222. * Base class for the main features of a material in Babylon.js
  20223. */
  20224. export class Material implements IAnimatable {
  20225. /**
  20226. * Returns the triangle fill mode
  20227. */
  20228. static readonly TriangleFillMode: number;
  20229. /**
  20230. * Returns the wireframe mode
  20231. */
  20232. static readonly WireFrameFillMode: number;
  20233. /**
  20234. * Returns the point fill mode
  20235. */
  20236. static readonly PointFillMode: number;
  20237. /**
  20238. * Returns the point list draw mode
  20239. */
  20240. static readonly PointListDrawMode: number;
  20241. /**
  20242. * Returns the line list draw mode
  20243. */
  20244. static readonly LineListDrawMode: number;
  20245. /**
  20246. * Returns the line loop draw mode
  20247. */
  20248. static readonly LineLoopDrawMode: number;
  20249. /**
  20250. * Returns the line strip draw mode
  20251. */
  20252. static readonly LineStripDrawMode: number;
  20253. /**
  20254. * Returns the triangle strip draw mode
  20255. */
  20256. static readonly TriangleStripDrawMode: number;
  20257. /**
  20258. * Returns the triangle fan draw mode
  20259. */
  20260. static readonly TriangleFanDrawMode: number;
  20261. /**
  20262. * Stores the clock-wise side orientation
  20263. */
  20264. static readonly ClockWiseSideOrientation: number;
  20265. /**
  20266. * Stores the counter clock-wise side orientation
  20267. */
  20268. static readonly CounterClockWiseSideOrientation: number;
  20269. /**
  20270. * The dirty texture flag value
  20271. */
  20272. static readonly TextureDirtyFlag: number;
  20273. /**
  20274. * The dirty light flag value
  20275. */
  20276. static readonly LightDirtyFlag: number;
  20277. /**
  20278. * The dirty fresnel flag value
  20279. */
  20280. static readonly FresnelDirtyFlag: number;
  20281. /**
  20282. * The dirty attribute flag value
  20283. */
  20284. static readonly AttributesDirtyFlag: number;
  20285. /**
  20286. * The dirty misc flag value
  20287. */
  20288. static readonly MiscDirtyFlag: number;
  20289. /**
  20290. * The all dirty flag value
  20291. */
  20292. static readonly AllDirtyFlag: number;
  20293. /**
  20294. * The ID of the material
  20295. */
  20296. id: string;
  20297. /**
  20298. * Gets or sets the unique id of the material
  20299. */
  20300. uniqueId: number;
  20301. /**
  20302. * The name of the material
  20303. */
  20304. name: string;
  20305. /**
  20306. * Gets or sets user defined metadata
  20307. */
  20308. metadata: any;
  20309. /**
  20310. * For internal use only. Please do not use.
  20311. */
  20312. reservedDataStore: any;
  20313. /**
  20314. * Specifies if the ready state should be checked on each call
  20315. */
  20316. checkReadyOnEveryCall: boolean;
  20317. /**
  20318. * Specifies if the ready state should be checked once
  20319. */
  20320. checkReadyOnlyOnce: boolean;
  20321. /**
  20322. * The state of the material
  20323. */
  20324. state: string;
  20325. /**
  20326. * The alpha value of the material
  20327. */
  20328. protected _alpha: number;
  20329. /**
  20330. * List of inspectable custom properties (used by the Inspector)
  20331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20332. */
  20333. inspectableCustomProperties: IInspectable[];
  20334. /**
  20335. * Sets the alpha value of the material
  20336. */
  20337. /**
  20338. * Gets the alpha value of the material
  20339. */
  20340. alpha: number;
  20341. /**
  20342. * Specifies if back face culling is enabled
  20343. */
  20344. protected _backFaceCulling: boolean;
  20345. /**
  20346. * Sets the back-face culling state
  20347. */
  20348. /**
  20349. * Gets the back-face culling state
  20350. */
  20351. backFaceCulling: boolean;
  20352. /**
  20353. * Stores the value for side orientation
  20354. */
  20355. sideOrientation: number;
  20356. /**
  20357. * Callback triggered when the material is compiled
  20358. */
  20359. onCompiled: Nullable<(effect: Effect) => void>;
  20360. /**
  20361. * Callback triggered when an error occurs
  20362. */
  20363. onError: Nullable<(effect: Effect, errors: string) => void>;
  20364. /**
  20365. * Callback triggered to get the render target textures
  20366. */
  20367. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20368. /**
  20369. * Gets a boolean indicating that current material needs to register RTT
  20370. */
  20371. readonly hasRenderTargetTextures: boolean;
  20372. /**
  20373. * Specifies if the material should be serialized
  20374. */
  20375. doNotSerialize: boolean;
  20376. /**
  20377. * @hidden
  20378. */
  20379. _storeEffectOnSubMeshes: boolean;
  20380. /**
  20381. * Stores the animations for the material
  20382. */
  20383. animations: Nullable<Array<Animation>>;
  20384. /**
  20385. * An event triggered when the material is disposed
  20386. */
  20387. onDisposeObservable: Observable<Material>;
  20388. /**
  20389. * An observer which watches for dispose events
  20390. */
  20391. private _onDisposeObserver;
  20392. private _onUnBindObservable;
  20393. /**
  20394. * Called during a dispose event
  20395. */
  20396. onDispose: () => void;
  20397. private _onBindObservable;
  20398. /**
  20399. * An event triggered when the material is bound
  20400. */
  20401. readonly onBindObservable: Observable<AbstractMesh>;
  20402. /**
  20403. * An observer which watches for bind events
  20404. */
  20405. private _onBindObserver;
  20406. /**
  20407. * Called during a bind event
  20408. */
  20409. onBind: (Mesh: AbstractMesh) => void;
  20410. /**
  20411. * An event triggered when the material is unbound
  20412. */
  20413. readonly onUnBindObservable: Observable<Material>;
  20414. /**
  20415. * Stores the value of the alpha mode
  20416. */
  20417. private _alphaMode;
  20418. /**
  20419. * Sets the value of the alpha mode.
  20420. *
  20421. * | Value | Type | Description |
  20422. * | --- | --- | --- |
  20423. * | 0 | ALPHA_DISABLE | |
  20424. * | 1 | ALPHA_ADD | |
  20425. * | 2 | ALPHA_COMBINE | |
  20426. * | 3 | ALPHA_SUBTRACT | |
  20427. * | 4 | ALPHA_MULTIPLY | |
  20428. * | 5 | ALPHA_MAXIMIZED | |
  20429. * | 6 | ALPHA_ONEONE | |
  20430. * | 7 | ALPHA_PREMULTIPLIED | |
  20431. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20432. * | 9 | ALPHA_INTERPOLATE | |
  20433. * | 10 | ALPHA_SCREENMODE | |
  20434. *
  20435. */
  20436. /**
  20437. * Gets the value of the alpha mode
  20438. */
  20439. alphaMode: number;
  20440. /**
  20441. * Stores the state of the need depth pre-pass value
  20442. */
  20443. private _needDepthPrePass;
  20444. /**
  20445. * Sets the need depth pre-pass value
  20446. */
  20447. /**
  20448. * Gets the depth pre-pass value
  20449. */
  20450. needDepthPrePass: boolean;
  20451. /**
  20452. * Specifies if depth writing should be disabled
  20453. */
  20454. disableDepthWrite: boolean;
  20455. /**
  20456. * Specifies if depth writing should be forced
  20457. */
  20458. forceDepthWrite: boolean;
  20459. /**
  20460. * Specifies if there should be a separate pass for culling
  20461. */
  20462. separateCullingPass: boolean;
  20463. /**
  20464. * Stores the state specifing if fog should be enabled
  20465. */
  20466. private _fogEnabled;
  20467. /**
  20468. * Sets the state for enabling fog
  20469. */
  20470. /**
  20471. * Gets the value of the fog enabled state
  20472. */
  20473. fogEnabled: boolean;
  20474. /**
  20475. * Stores the size of points
  20476. */
  20477. pointSize: number;
  20478. /**
  20479. * Stores the z offset value
  20480. */
  20481. zOffset: number;
  20482. /**
  20483. * Gets a value specifying if wireframe mode is enabled
  20484. */
  20485. /**
  20486. * Sets the state of wireframe mode
  20487. */
  20488. wireframe: boolean;
  20489. /**
  20490. * Gets the value specifying if point clouds are enabled
  20491. */
  20492. /**
  20493. * Sets the state of point cloud mode
  20494. */
  20495. pointsCloud: boolean;
  20496. /**
  20497. * Gets the material fill mode
  20498. */
  20499. /**
  20500. * Sets the material fill mode
  20501. */
  20502. fillMode: number;
  20503. /**
  20504. * @hidden
  20505. * Stores the effects for the material
  20506. */
  20507. _effect: Nullable<Effect>;
  20508. /**
  20509. * @hidden
  20510. * Specifies if the material was previously ready
  20511. */
  20512. _wasPreviouslyReady: boolean;
  20513. /**
  20514. * Specifies if uniform buffers should be used
  20515. */
  20516. private _useUBO;
  20517. /**
  20518. * Stores a reference to the scene
  20519. */
  20520. private _scene;
  20521. /**
  20522. * Stores the fill mode state
  20523. */
  20524. private _fillMode;
  20525. /**
  20526. * Specifies if the depth write state should be cached
  20527. */
  20528. private _cachedDepthWriteState;
  20529. /**
  20530. * Stores the uniform buffer
  20531. */
  20532. protected _uniformBuffer: UniformBuffer;
  20533. /** @hidden */
  20534. _indexInSceneMaterialArray: number;
  20535. /** @hidden */
  20536. meshMap: Nullable<{
  20537. [id: string]: AbstractMesh | undefined;
  20538. }>;
  20539. /**
  20540. * Creates a material instance
  20541. * @param name defines the name of the material
  20542. * @param scene defines the scene to reference
  20543. * @param doNotAdd specifies if the material should be added to the scene
  20544. */
  20545. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20546. /**
  20547. * Returns a string representation of the current material
  20548. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20549. * @returns a string with material information
  20550. */
  20551. toString(fullDetails?: boolean): string;
  20552. /**
  20553. * Gets the class name of the material
  20554. * @returns a string with the class name of the material
  20555. */
  20556. getClassName(): string;
  20557. /**
  20558. * Specifies if updates for the material been locked
  20559. */
  20560. readonly isFrozen: boolean;
  20561. /**
  20562. * Locks updates for the material
  20563. */
  20564. freeze(): void;
  20565. /**
  20566. * Unlocks updates for the material
  20567. */
  20568. unfreeze(): void;
  20569. /**
  20570. * Specifies if the material is ready to be used
  20571. * @param mesh defines the mesh to check
  20572. * @param useInstances specifies if instances should be used
  20573. * @returns a boolean indicating if the material is ready to be used
  20574. */
  20575. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20576. /**
  20577. * Specifies that the submesh is ready to be used
  20578. * @param mesh defines the mesh to check
  20579. * @param subMesh defines which submesh to check
  20580. * @param useInstances specifies that instances should be used
  20581. * @returns a boolean indicating that the submesh is ready or not
  20582. */
  20583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20584. /**
  20585. * Returns the material effect
  20586. * @returns the effect associated with the material
  20587. */
  20588. getEffect(): Nullable<Effect>;
  20589. /**
  20590. * Returns the current scene
  20591. * @returns a Scene
  20592. */
  20593. getScene(): Scene;
  20594. /**
  20595. * Specifies if the material will require alpha blending
  20596. * @returns a boolean specifying if alpha blending is needed
  20597. */
  20598. needAlphaBlending(): boolean;
  20599. /**
  20600. * Specifies if the mesh will require alpha blending
  20601. * @param mesh defines the mesh to check
  20602. * @returns a boolean specifying if alpha blending is needed for the mesh
  20603. */
  20604. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20605. /**
  20606. * Specifies if this material should be rendered in alpha test mode
  20607. * @returns a boolean specifying if an alpha test is needed.
  20608. */
  20609. needAlphaTesting(): boolean;
  20610. /**
  20611. * Gets the texture used for the alpha test
  20612. * @returns the texture to use for alpha testing
  20613. */
  20614. getAlphaTestTexture(): Nullable<BaseTexture>;
  20615. /**
  20616. * Marks the material to indicate that it needs to be re-calculated
  20617. */
  20618. markDirty(): void;
  20619. /** @hidden */
  20620. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20621. /**
  20622. * Binds the material to the mesh
  20623. * @param world defines the world transformation matrix
  20624. * @param mesh defines the mesh to bind the material to
  20625. */
  20626. bind(world: Matrix, mesh?: Mesh): void;
  20627. /**
  20628. * Binds the submesh to the material
  20629. * @param world defines the world transformation matrix
  20630. * @param mesh defines the mesh containing the submesh
  20631. * @param subMesh defines the submesh to bind the material to
  20632. */
  20633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20634. /**
  20635. * Binds the world matrix to the material
  20636. * @param world defines the world transformation matrix
  20637. */
  20638. bindOnlyWorldMatrix(world: Matrix): void;
  20639. /**
  20640. * Binds the scene's uniform buffer to the effect.
  20641. * @param effect defines the effect to bind to the scene uniform buffer
  20642. * @param sceneUbo defines the uniform buffer storing scene data
  20643. */
  20644. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20645. /**
  20646. * Binds the view matrix to the effect
  20647. * @param effect defines the effect to bind the view matrix to
  20648. */
  20649. bindView(effect: Effect): void;
  20650. /**
  20651. * Binds the view projection matrix to the effect
  20652. * @param effect defines the effect to bind the view projection matrix to
  20653. */
  20654. bindViewProjection(effect: Effect): void;
  20655. /**
  20656. * Specifies if material alpha testing should be turned on for the mesh
  20657. * @param mesh defines the mesh to check
  20658. */
  20659. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20660. /**
  20661. * Processes to execute after binding the material to a mesh
  20662. * @param mesh defines the rendered mesh
  20663. */
  20664. protected _afterBind(mesh?: Mesh): void;
  20665. /**
  20666. * Unbinds the material from the mesh
  20667. */
  20668. unbind(): void;
  20669. /**
  20670. * Gets the active textures from the material
  20671. * @returns an array of textures
  20672. */
  20673. getActiveTextures(): BaseTexture[];
  20674. /**
  20675. * Specifies if the material uses a texture
  20676. * @param texture defines the texture to check against the material
  20677. * @returns a boolean specifying if the material uses the texture
  20678. */
  20679. hasTexture(texture: BaseTexture): boolean;
  20680. /**
  20681. * Makes a duplicate of the material, and gives it a new name
  20682. * @param name defines the new name for the duplicated material
  20683. * @returns the cloned material
  20684. */
  20685. clone(name: string): Nullable<Material>;
  20686. /**
  20687. * Gets the meshes bound to the material
  20688. * @returns an array of meshes bound to the material
  20689. */
  20690. getBindedMeshes(): AbstractMesh[];
  20691. /**
  20692. * Force shader compilation
  20693. * @param mesh defines the mesh associated with this material
  20694. * @param onCompiled defines a function to execute once the material is compiled
  20695. * @param options defines the options to configure the compilation
  20696. * @param onError defines a function to execute if the material fails compiling
  20697. */
  20698. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20699. /**
  20700. * Force shader compilation
  20701. * @param mesh defines the mesh that will use this material
  20702. * @param options defines additional options for compiling the shaders
  20703. * @returns a promise that resolves when the compilation completes
  20704. */
  20705. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20706. private static readonly _AllDirtyCallBack;
  20707. private static readonly _ImageProcessingDirtyCallBack;
  20708. private static readonly _TextureDirtyCallBack;
  20709. private static readonly _FresnelDirtyCallBack;
  20710. private static readonly _MiscDirtyCallBack;
  20711. private static readonly _LightsDirtyCallBack;
  20712. private static readonly _AttributeDirtyCallBack;
  20713. private static _FresnelAndMiscDirtyCallBack;
  20714. private static _TextureAndMiscDirtyCallBack;
  20715. private static readonly _DirtyCallbackArray;
  20716. private static readonly _RunDirtyCallBacks;
  20717. /**
  20718. * Marks a define in the material to indicate that it needs to be re-computed
  20719. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20720. */
  20721. markAsDirty(flag: number): void;
  20722. /**
  20723. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20724. * @param func defines a function which checks material defines against the submeshes
  20725. */
  20726. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20727. /**
  20728. * Indicates that we need to re-calculated for all submeshes
  20729. */
  20730. protected _markAllSubMeshesAsAllDirty(): void;
  20731. /**
  20732. * Indicates that image processing needs to be re-calculated for all submeshes
  20733. */
  20734. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20735. /**
  20736. * Indicates that textures need to be re-calculated for all submeshes
  20737. */
  20738. protected _markAllSubMeshesAsTexturesDirty(): void;
  20739. /**
  20740. * Indicates that fresnel needs to be re-calculated for all submeshes
  20741. */
  20742. protected _markAllSubMeshesAsFresnelDirty(): void;
  20743. /**
  20744. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20745. */
  20746. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20747. /**
  20748. * Indicates that lights need to be re-calculated for all submeshes
  20749. */
  20750. protected _markAllSubMeshesAsLightsDirty(): void;
  20751. /**
  20752. * Indicates that attributes need to be re-calculated for all submeshes
  20753. */
  20754. protected _markAllSubMeshesAsAttributesDirty(): void;
  20755. /**
  20756. * Indicates that misc needs to be re-calculated for all submeshes
  20757. */
  20758. protected _markAllSubMeshesAsMiscDirty(): void;
  20759. /**
  20760. * Indicates that textures and misc need to be re-calculated for all submeshes
  20761. */
  20762. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20763. /**
  20764. * Disposes the material
  20765. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20766. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20767. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20768. */
  20769. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20770. /** @hidden */
  20771. private releaseVertexArrayObject;
  20772. /**
  20773. * Serializes this material
  20774. * @returns the serialized material object
  20775. */
  20776. serialize(): any;
  20777. /**
  20778. * Creates a material from parsed material data
  20779. * @param parsedMaterial defines parsed material data
  20780. * @param scene defines the hosting scene
  20781. * @param rootUrl defines the root URL to use to load textures
  20782. * @returns a new material
  20783. */
  20784. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20785. }
  20786. }
  20787. declare module BABYLON {
  20788. /**
  20789. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20790. * separate meshes. This can be use to improve performances.
  20791. * @see http://doc.babylonjs.com/how_to/multi_materials
  20792. */
  20793. export class MultiMaterial extends Material {
  20794. private _subMaterials;
  20795. /**
  20796. * Gets or Sets the list of Materials used within the multi material.
  20797. * They need to be ordered according to the submeshes order in the associated mesh
  20798. */
  20799. subMaterials: Nullable<Material>[];
  20800. /**
  20801. * Function used to align with Node.getChildren()
  20802. * @returns the list of Materials used within the multi material
  20803. */
  20804. getChildren(): Nullable<Material>[];
  20805. /**
  20806. * Instantiates a new Multi Material
  20807. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20808. * separate meshes. This can be use to improve performances.
  20809. * @see http://doc.babylonjs.com/how_to/multi_materials
  20810. * @param name Define the name in the scene
  20811. * @param scene Define the scene the material belongs to
  20812. */
  20813. constructor(name: string, scene: Scene);
  20814. private _hookArray;
  20815. /**
  20816. * Get one of the submaterial by its index in the submaterials array
  20817. * @param index The index to look the sub material at
  20818. * @returns The Material if the index has been defined
  20819. */
  20820. getSubMaterial(index: number): Nullable<Material>;
  20821. /**
  20822. * Get the list of active textures for the whole sub materials list.
  20823. * @returns All the textures that will be used during the rendering
  20824. */
  20825. getActiveTextures(): BaseTexture[];
  20826. /**
  20827. * Gets the current class name of the material e.g. "MultiMaterial"
  20828. * Mainly use in serialization.
  20829. * @returns the class name
  20830. */
  20831. getClassName(): string;
  20832. /**
  20833. * Checks if the material is ready to render the requested sub mesh
  20834. * @param mesh Define the mesh the submesh belongs to
  20835. * @param subMesh Define the sub mesh to look readyness for
  20836. * @param useInstances Define whether or not the material is used with instances
  20837. * @returns true if ready, otherwise false
  20838. */
  20839. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20840. /**
  20841. * Clones the current material and its related sub materials
  20842. * @param name Define the name of the newly cloned material
  20843. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20844. * @returns the cloned material
  20845. */
  20846. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20847. /**
  20848. * Serializes the materials into a JSON representation.
  20849. * @returns the JSON representation
  20850. */
  20851. serialize(): any;
  20852. /**
  20853. * Dispose the material and release its associated resources
  20854. * @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)
  20855. * @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)
  20856. * @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)
  20857. */
  20858. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20859. /**
  20860. * Creates a MultiMaterial from parsed MultiMaterial data.
  20861. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20862. * @param scene defines the hosting scene
  20863. * @returns a new MultiMaterial
  20864. */
  20865. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20866. }
  20867. }
  20868. declare module BABYLON {
  20869. /**
  20870. * Base class for submeshes
  20871. */
  20872. export class BaseSubMesh {
  20873. /** @hidden */
  20874. _materialDefines: Nullable<MaterialDefines>;
  20875. /** @hidden */
  20876. _materialEffect: Nullable<Effect>;
  20877. /**
  20878. * Gets associated effect
  20879. */
  20880. readonly effect: Nullable<Effect>;
  20881. /**
  20882. * Sets associated effect (effect used to render this submesh)
  20883. * @param effect defines the effect to associate with
  20884. * @param defines defines the set of defines used to compile this effect
  20885. */
  20886. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20887. }
  20888. /**
  20889. * Defines a subdivision inside a mesh
  20890. */
  20891. export class SubMesh extends BaseSubMesh implements ICullable {
  20892. /** the material index to use */
  20893. materialIndex: number;
  20894. /** vertex index start */
  20895. verticesStart: number;
  20896. /** vertices count */
  20897. verticesCount: number;
  20898. /** index start */
  20899. indexStart: number;
  20900. /** indices count */
  20901. indexCount: number;
  20902. /** @hidden */
  20903. _linesIndexCount: number;
  20904. private _mesh;
  20905. private _renderingMesh;
  20906. private _boundingInfo;
  20907. private _linesIndexBuffer;
  20908. /** @hidden */
  20909. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20910. /** @hidden */
  20911. _trianglePlanes: Plane[];
  20912. /** @hidden */
  20913. _lastColliderTransformMatrix: Nullable<Matrix>;
  20914. /** @hidden */
  20915. _renderId: number;
  20916. /** @hidden */
  20917. _alphaIndex: number;
  20918. /** @hidden */
  20919. _distanceToCamera: number;
  20920. /** @hidden */
  20921. _id: number;
  20922. private _currentMaterial;
  20923. /**
  20924. * Add a new submesh to a mesh
  20925. * @param materialIndex defines the material index to use
  20926. * @param verticesStart defines vertex index start
  20927. * @param verticesCount defines vertices count
  20928. * @param indexStart defines index start
  20929. * @param indexCount defines indices count
  20930. * @param mesh defines the parent mesh
  20931. * @param renderingMesh defines an optional rendering mesh
  20932. * @param createBoundingBox defines if bounding box should be created for this submesh
  20933. * @returns the new submesh
  20934. */
  20935. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20936. /**
  20937. * Creates a new submesh
  20938. * @param materialIndex defines the material index to use
  20939. * @param verticesStart defines vertex index start
  20940. * @param verticesCount defines vertices count
  20941. * @param indexStart defines index start
  20942. * @param indexCount defines indices count
  20943. * @param mesh defines the parent mesh
  20944. * @param renderingMesh defines an optional rendering mesh
  20945. * @param createBoundingBox defines if bounding box should be created for this submesh
  20946. */
  20947. constructor(
  20948. /** the material index to use */
  20949. materialIndex: number,
  20950. /** vertex index start */
  20951. verticesStart: number,
  20952. /** vertices count */
  20953. verticesCount: number,
  20954. /** index start */
  20955. indexStart: number,
  20956. /** indices count */
  20957. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20958. /**
  20959. * Returns true if this submesh covers the entire parent mesh
  20960. * @ignorenaming
  20961. */
  20962. readonly IsGlobal: boolean;
  20963. /**
  20964. * Returns the submesh BoudingInfo object
  20965. * @returns current bounding info (or mesh's one if the submesh is global)
  20966. */
  20967. getBoundingInfo(): BoundingInfo;
  20968. /**
  20969. * Sets the submesh BoundingInfo
  20970. * @param boundingInfo defines the new bounding info to use
  20971. * @returns the SubMesh
  20972. */
  20973. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20974. /**
  20975. * Returns the mesh of the current submesh
  20976. * @return the parent mesh
  20977. */
  20978. getMesh(): AbstractMesh;
  20979. /**
  20980. * Returns the rendering mesh of the submesh
  20981. * @returns the rendering mesh (could be different from parent mesh)
  20982. */
  20983. getRenderingMesh(): Mesh;
  20984. /**
  20985. * Returns the submesh material
  20986. * @returns null or the current material
  20987. */
  20988. getMaterial(): Nullable<Material>;
  20989. /**
  20990. * Sets a new updated BoundingInfo object to the submesh
  20991. * @param data defines an optional position array to use to determine the bounding info
  20992. * @returns the SubMesh
  20993. */
  20994. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20995. /** @hidden */
  20996. _checkCollision(collider: Collider): boolean;
  20997. /**
  20998. * Updates the submesh BoundingInfo
  20999. * @param world defines the world matrix to use to update the bounding info
  21000. * @returns the submesh
  21001. */
  21002. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21003. /**
  21004. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21005. * @param frustumPlanes defines the frustum planes
  21006. * @returns true if the submesh is intersecting with the frustum
  21007. */
  21008. isInFrustum(frustumPlanes: Plane[]): boolean;
  21009. /**
  21010. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21011. * @param frustumPlanes defines the frustum planes
  21012. * @returns true if the submesh is inside the frustum
  21013. */
  21014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21015. /**
  21016. * Renders the submesh
  21017. * @param enableAlphaMode defines if alpha needs to be used
  21018. * @returns the submesh
  21019. */
  21020. render(enableAlphaMode: boolean): SubMesh;
  21021. /**
  21022. * @hidden
  21023. */
  21024. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21025. /**
  21026. * Checks if the submesh intersects with a ray
  21027. * @param ray defines the ray to test
  21028. * @returns true is the passed ray intersects the submesh bounding box
  21029. */
  21030. canIntersects(ray: Ray): boolean;
  21031. /**
  21032. * Intersects current submesh with a ray
  21033. * @param ray defines the ray to test
  21034. * @param positions defines mesh's positions array
  21035. * @param indices defines mesh's indices array
  21036. * @param fastCheck defines if only bounding info should be used
  21037. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21038. * @returns intersection info or null if no intersection
  21039. */
  21040. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21041. /** @hidden */
  21042. private _intersectLines;
  21043. /** @hidden */
  21044. private _intersectUnIndexedLines;
  21045. /** @hidden */
  21046. private _intersectTriangles;
  21047. /** @hidden */
  21048. private _intersectUnIndexedTriangles;
  21049. /** @hidden */
  21050. _rebuild(): void;
  21051. /**
  21052. * Creates a new submesh from the passed mesh
  21053. * @param newMesh defines the new hosting mesh
  21054. * @param newRenderingMesh defines an optional rendering mesh
  21055. * @returns the new submesh
  21056. */
  21057. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21058. /**
  21059. * Release associated resources
  21060. */
  21061. dispose(): void;
  21062. /**
  21063. * Gets the class name
  21064. * @returns the string "SubMesh".
  21065. */
  21066. getClassName(): string;
  21067. /**
  21068. * Creates a new submesh from indices data
  21069. * @param materialIndex the index of the main mesh material
  21070. * @param startIndex the index where to start the copy in the mesh indices array
  21071. * @param indexCount the number of indices to copy then from the startIndex
  21072. * @param mesh the main mesh to create the submesh from
  21073. * @param renderingMesh the optional rendering mesh
  21074. * @returns a new submesh
  21075. */
  21076. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21077. }
  21078. }
  21079. declare module BABYLON {
  21080. /**
  21081. * Class used to represent data loading progression
  21082. */
  21083. export class SceneLoaderFlags {
  21084. private static _ForceFullSceneLoadingForIncremental;
  21085. private static _ShowLoadingScreen;
  21086. private static _CleanBoneMatrixWeights;
  21087. private static _loggingLevel;
  21088. /**
  21089. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21090. */
  21091. static ForceFullSceneLoadingForIncremental: boolean;
  21092. /**
  21093. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21094. */
  21095. static ShowLoadingScreen: boolean;
  21096. /**
  21097. * Defines the current logging level (while loading the scene)
  21098. * @ignorenaming
  21099. */
  21100. static loggingLevel: number;
  21101. /**
  21102. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21103. */
  21104. static CleanBoneMatrixWeights: boolean;
  21105. }
  21106. }
  21107. declare module BABYLON {
  21108. /**
  21109. * Class used to store geometry data (vertex buffers + index buffer)
  21110. */
  21111. export class Geometry implements IGetSetVerticesData {
  21112. /**
  21113. * Gets or sets the ID of the geometry
  21114. */
  21115. id: string;
  21116. /**
  21117. * Gets or sets the unique ID of the geometry
  21118. */
  21119. uniqueId: number;
  21120. /**
  21121. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21122. */
  21123. delayLoadState: number;
  21124. /**
  21125. * Gets the file containing the data to load when running in delay load state
  21126. */
  21127. delayLoadingFile: Nullable<string>;
  21128. /**
  21129. * Callback called when the geometry is updated
  21130. */
  21131. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21132. private _scene;
  21133. private _engine;
  21134. private _meshes;
  21135. private _totalVertices;
  21136. /** @hidden */
  21137. _indices: IndicesArray;
  21138. /** @hidden */
  21139. _vertexBuffers: {
  21140. [key: string]: VertexBuffer;
  21141. };
  21142. private _isDisposed;
  21143. private _extend;
  21144. private _boundingBias;
  21145. /** @hidden */
  21146. _delayInfo: Array<string>;
  21147. private _indexBuffer;
  21148. private _indexBufferIsUpdatable;
  21149. /** @hidden */
  21150. _boundingInfo: Nullable<BoundingInfo>;
  21151. /** @hidden */
  21152. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21153. /** @hidden */
  21154. _softwareSkinningFrameId: number;
  21155. private _vertexArrayObjects;
  21156. private _updatable;
  21157. /** @hidden */
  21158. _positions: Nullable<Vector3[]>;
  21159. /**
  21160. * 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
  21161. */
  21162. /**
  21163. * 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
  21164. */
  21165. boundingBias: Vector2;
  21166. /**
  21167. * Static function used to attach a new empty geometry to a mesh
  21168. * @param mesh defines the mesh to attach the geometry to
  21169. * @returns the new Geometry
  21170. */
  21171. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21172. /**
  21173. * Creates a new geometry
  21174. * @param id defines the unique ID
  21175. * @param scene defines the hosting scene
  21176. * @param vertexData defines the VertexData used to get geometry data
  21177. * @param updatable defines if geometry must be updatable (false by default)
  21178. * @param mesh defines the mesh that will be associated with the geometry
  21179. */
  21180. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21181. /**
  21182. * Gets the current extend of the geometry
  21183. */
  21184. readonly extend: {
  21185. minimum: Vector3;
  21186. maximum: Vector3;
  21187. };
  21188. /**
  21189. * Gets the hosting scene
  21190. * @returns the hosting Scene
  21191. */
  21192. getScene(): Scene;
  21193. /**
  21194. * Gets the hosting engine
  21195. * @returns the hosting Engine
  21196. */
  21197. getEngine(): Engine;
  21198. /**
  21199. * Defines if the geometry is ready to use
  21200. * @returns true if the geometry is ready to be used
  21201. */
  21202. isReady(): boolean;
  21203. /**
  21204. * Gets a value indicating that the geometry should not be serialized
  21205. */
  21206. readonly doNotSerialize: boolean;
  21207. /** @hidden */
  21208. _rebuild(): void;
  21209. /**
  21210. * Affects all geometry data in one call
  21211. * @param vertexData defines the geometry data
  21212. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21213. */
  21214. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21215. /**
  21216. * Set specific vertex data
  21217. * @param kind defines the data kind (Position, normal, etc...)
  21218. * @param data defines the vertex data to use
  21219. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21220. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21221. */
  21222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21223. /**
  21224. * Removes a specific vertex data
  21225. * @param kind defines the data kind (Position, normal, etc...)
  21226. */
  21227. removeVerticesData(kind: string): void;
  21228. /**
  21229. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21230. * @param buffer defines the vertex buffer to use
  21231. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21232. */
  21233. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21234. /**
  21235. * Update a specific vertex buffer
  21236. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21237. * It will do nothing if the buffer is not updatable
  21238. * @param kind defines the data kind (Position, normal, etc...)
  21239. * @param data defines the data to use
  21240. * @param offset defines the offset in the target buffer where to store the data
  21241. * @param useBytes set to true if the offset is in bytes
  21242. */
  21243. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21244. /**
  21245. * Update a specific vertex buffer
  21246. * This function will create a new buffer if the current one is not updatable
  21247. * @param kind defines the data kind (Position, normal, etc...)
  21248. * @param data defines the data to use
  21249. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21250. */
  21251. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21252. private _updateBoundingInfo;
  21253. /** @hidden */
  21254. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21255. /**
  21256. * Gets total number of vertices
  21257. * @returns the total number of vertices
  21258. */
  21259. getTotalVertices(): number;
  21260. /**
  21261. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21262. * @param kind defines the data kind (Position, normal, etc...)
  21263. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21264. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21265. * @returns a float array containing vertex data
  21266. */
  21267. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21268. /**
  21269. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21270. * @param kind defines the data kind (Position, normal, etc...)
  21271. * @returns true if the vertex buffer with the specified kind is updatable
  21272. */
  21273. isVertexBufferUpdatable(kind: string): boolean;
  21274. /**
  21275. * Gets a specific vertex buffer
  21276. * @param kind defines the data kind (Position, normal, etc...)
  21277. * @returns a VertexBuffer
  21278. */
  21279. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21280. /**
  21281. * Returns all vertex buffers
  21282. * @return an object holding all vertex buffers indexed by kind
  21283. */
  21284. getVertexBuffers(): Nullable<{
  21285. [key: string]: VertexBuffer;
  21286. }>;
  21287. /**
  21288. * Gets a boolean indicating if specific vertex buffer is present
  21289. * @param kind defines the data kind (Position, normal, etc...)
  21290. * @returns true if data is present
  21291. */
  21292. isVerticesDataPresent(kind: string): boolean;
  21293. /**
  21294. * Gets a list of all attached data kinds (Position, normal, etc...)
  21295. * @returns a list of string containing all kinds
  21296. */
  21297. getVerticesDataKinds(): string[];
  21298. /**
  21299. * Update index buffer
  21300. * @param indices defines the indices to store in the index buffer
  21301. * @param offset defines the offset in the target buffer where to store the data
  21302. * @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)
  21303. */
  21304. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21305. /**
  21306. * Creates a new index buffer
  21307. * @param indices defines the indices to store in the index buffer
  21308. * @param totalVertices defines the total number of vertices (could be null)
  21309. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21310. */
  21311. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21312. /**
  21313. * Return the total number of indices
  21314. * @returns the total number of indices
  21315. */
  21316. getTotalIndices(): number;
  21317. /**
  21318. * Gets the index buffer array
  21319. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21320. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21321. * @returns the index buffer array
  21322. */
  21323. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21324. /**
  21325. * Gets the index buffer
  21326. * @return the index buffer
  21327. */
  21328. getIndexBuffer(): Nullable<DataBuffer>;
  21329. /** @hidden */
  21330. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21331. /**
  21332. * Release the associated resources for a specific mesh
  21333. * @param mesh defines the source mesh
  21334. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21335. */
  21336. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21337. /**
  21338. * Apply current geometry to a given mesh
  21339. * @param mesh defines the mesh to apply geometry to
  21340. */
  21341. applyToMesh(mesh: Mesh): void;
  21342. private _updateExtend;
  21343. private _applyToMesh;
  21344. private notifyUpdate;
  21345. /**
  21346. * Load the geometry if it was flagged as delay loaded
  21347. * @param scene defines the hosting scene
  21348. * @param onLoaded defines a callback called when the geometry is loaded
  21349. */
  21350. load(scene: Scene, onLoaded?: () => void): void;
  21351. private _queueLoad;
  21352. /**
  21353. * Invert the geometry to move from a right handed system to a left handed one.
  21354. */
  21355. toLeftHanded(): void;
  21356. /** @hidden */
  21357. _resetPointsArrayCache(): void;
  21358. /** @hidden */
  21359. _generatePointsArray(): boolean;
  21360. /**
  21361. * Gets a value indicating if the geometry is disposed
  21362. * @returns true if the geometry was disposed
  21363. */
  21364. isDisposed(): boolean;
  21365. private _disposeVertexArrayObjects;
  21366. /**
  21367. * Free all associated resources
  21368. */
  21369. dispose(): void;
  21370. /**
  21371. * Clone the current geometry into a new geometry
  21372. * @param id defines the unique ID of the new geometry
  21373. * @returns a new geometry object
  21374. */
  21375. copy(id: string): Geometry;
  21376. /**
  21377. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21378. * @return a JSON representation of the current geometry data (without the vertices data)
  21379. */
  21380. serialize(): any;
  21381. private toNumberArray;
  21382. /**
  21383. * Serialize all vertices data into a JSON oject
  21384. * @returns a JSON representation of the current geometry data
  21385. */
  21386. serializeVerticeData(): any;
  21387. /**
  21388. * Extracts a clone of a mesh geometry
  21389. * @param mesh defines the source mesh
  21390. * @param id defines the unique ID of the new geometry object
  21391. * @returns the new geometry object
  21392. */
  21393. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21394. /**
  21395. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21396. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21397. * Be aware Math.random() could cause collisions, but:
  21398. * "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"
  21399. * @returns a string containing a new GUID
  21400. */
  21401. static RandomId(): string;
  21402. /** @hidden */
  21403. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21404. private static _CleanMatricesWeights;
  21405. /**
  21406. * Create a new geometry from persisted data (Using .babylon file format)
  21407. * @param parsedVertexData defines the persisted data
  21408. * @param scene defines the hosting scene
  21409. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21410. * @returns the new geometry object
  21411. */
  21412. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21413. }
  21414. }
  21415. declare module BABYLON {
  21416. /**
  21417. * Define an interface for all classes that will get and set the data on vertices
  21418. */
  21419. export interface IGetSetVerticesData {
  21420. /**
  21421. * Gets a boolean indicating if specific vertex data is present
  21422. * @param kind defines the vertex data kind to use
  21423. * @returns true is data kind is present
  21424. */
  21425. isVerticesDataPresent(kind: string): boolean;
  21426. /**
  21427. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21428. * @param kind defines the data kind (Position, normal, etc...)
  21429. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21430. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21431. * @returns a float array containing vertex data
  21432. */
  21433. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21434. /**
  21435. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21436. * @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.
  21437. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21438. * @returns the indices array or an empty array if the mesh has no geometry
  21439. */
  21440. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21441. /**
  21442. * Set specific vertex data
  21443. * @param kind defines the data kind (Position, normal, etc...)
  21444. * @param data defines the vertex data to use
  21445. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21446. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21447. */
  21448. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21449. /**
  21450. * Update a specific associated vertex buffer
  21451. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21452. * - VertexBuffer.PositionKind
  21453. * - VertexBuffer.UVKind
  21454. * - VertexBuffer.UV2Kind
  21455. * - VertexBuffer.UV3Kind
  21456. * - VertexBuffer.UV4Kind
  21457. * - VertexBuffer.UV5Kind
  21458. * - VertexBuffer.UV6Kind
  21459. * - VertexBuffer.ColorKind
  21460. * - VertexBuffer.MatricesIndicesKind
  21461. * - VertexBuffer.MatricesIndicesExtraKind
  21462. * - VertexBuffer.MatricesWeightsKind
  21463. * - VertexBuffer.MatricesWeightsExtraKind
  21464. * @param data defines the data source
  21465. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21466. * @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)
  21467. */
  21468. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21469. /**
  21470. * Creates a new index buffer
  21471. * @param indices defines the indices to store in the index buffer
  21472. * @param totalVertices defines the total number of vertices (could be null)
  21473. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21474. */
  21475. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21476. }
  21477. /**
  21478. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21479. */
  21480. export class VertexData {
  21481. /**
  21482. * Mesh side orientation : usually the external or front surface
  21483. */
  21484. static readonly FRONTSIDE: number;
  21485. /**
  21486. * Mesh side orientation : usually the internal or back surface
  21487. */
  21488. static readonly BACKSIDE: number;
  21489. /**
  21490. * Mesh side orientation : both internal and external or front and back surfaces
  21491. */
  21492. static readonly DOUBLESIDE: number;
  21493. /**
  21494. * Mesh side orientation : by default, `FRONTSIDE`
  21495. */
  21496. static readonly DEFAULTSIDE: number;
  21497. /**
  21498. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21499. */
  21500. positions: Nullable<FloatArray>;
  21501. /**
  21502. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21503. */
  21504. normals: Nullable<FloatArray>;
  21505. /**
  21506. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21507. */
  21508. tangents: Nullable<FloatArray>;
  21509. /**
  21510. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21511. */
  21512. uvs: Nullable<FloatArray>;
  21513. /**
  21514. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21515. */
  21516. uvs2: Nullable<FloatArray>;
  21517. /**
  21518. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21519. */
  21520. uvs3: Nullable<FloatArray>;
  21521. /**
  21522. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21523. */
  21524. uvs4: Nullable<FloatArray>;
  21525. /**
  21526. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21527. */
  21528. uvs5: Nullable<FloatArray>;
  21529. /**
  21530. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21531. */
  21532. uvs6: Nullable<FloatArray>;
  21533. /**
  21534. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21535. */
  21536. colors: Nullable<FloatArray>;
  21537. /**
  21538. * 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).
  21539. */
  21540. matricesIndices: Nullable<FloatArray>;
  21541. /**
  21542. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21543. */
  21544. matricesWeights: Nullable<FloatArray>;
  21545. /**
  21546. * An array extending the number of possible indices
  21547. */
  21548. matricesIndicesExtra: Nullable<FloatArray>;
  21549. /**
  21550. * An array extending the number of possible weights when the number of indices is extended
  21551. */
  21552. matricesWeightsExtra: Nullable<FloatArray>;
  21553. /**
  21554. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21555. */
  21556. indices: Nullable<IndicesArray>;
  21557. /**
  21558. * Uses the passed data array to set the set the values for the specified kind of data
  21559. * @param data a linear array of floating numbers
  21560. * @param kind the type of data that is being set, eg positions, colors etc
  21561. */
  21562. set(data: FloatArray, kind: string): void;
  21563. /**
  21564. * Associates the vertexData to the passed Mesh.
  21565. * Sets it as updatable or not (default `false`)
  21566. * @param mesh the mesh the vertexData is applied to
  21567. * @param updatable when used and having the value true allows new data to update the vertexData
  21568. * @returns the VertexData
  21569. */
  21570. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21571. /**
  21572. * Associates the vertexData to the passed Geometry.
  21573. * Sets it as updatable or not (default `false`)
  21574. * @param geometry the geometry the vertexData is applied to
  21575. * @param updatable when used and having the value true allows new data to update the vertexData
  21576. * @returns VertexData
  21577. */
  21578. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21579. /**
  21580. * Updates the associated mesh
  21581. * @param mesh the mesh to be updated
  21582. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21583. * @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
  21584. * @returns VertexData
  21585. */
  21586. updateMesh(mesh: Mesh): VertexData;
  21587. /**
  21588. * Updates the associated geometry
  21589. * @param geometry the geometry to be updated
  21590. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21591. * @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
  21592. * @returns VertexData.
  21593. */
  21594. updateGeometry(geometry: Geometry): VertexData;
  21595. private _applyTo;
  21596. private _update;
  21597. /**
  21598. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21599. * @param matrix the transforming matrix
  21600. * @returns the VertexData
  21601. */
  21602. transform(matrix: Matrix): VertexData;
  21603. /**
  21604. * Merges the passed VertexData into the current one
  21605. * @param other the VertexData to be merged into the current one
  21606. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21607. * @returns the modified VertexData
  21608. */
  21609. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21610. private _mergeElement;
  21611. private _validate;
  21612. /**
  21613. * Serializes the VertexData
  21614. * @returns a serialized object
  21615. */
  21616. serialize(): any;
  21617. /**
  21618. * Extracts the vertexData from a mesh
  21619. * @param mesh the mesh from which to extract the VertexData
  21620. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21621. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21622. * @returns the object VertexData associated to the passed mesh
  21623. */
  21624. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21625. /**
  21626. * Extracts the vertexData from the geometry
  21627. * @param geometry the geometry from which to extract the VertexData
  21628. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21629. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21630. * @returns the object VertexData associated to the passed mesh
  21631. */
  21632. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21633. private static _ExtractFrom;
  21634. /**
  21635. * Creates the VertexData for a Ribbon
  21636. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21637. * * pathArray array of paths, each of which an array of successive Vector3
  21638. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21639. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21640. * * 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
  21641. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21642. * * 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)
  21643. * * 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)
  21644. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21645. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21646. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21647. * @returns the VertexData of the ribbon
  21648. */
  21649. static CreateRibbon(options: {
  21650. pathArray: Vector3[][];
  21651. closeArray?: boolean;
  21652. closePath?: boolean;
  21653. offset?: number;
  21654. sideOrientation?: number;
  21655. frontUVs?: Vector4;
  21656. backUVs?: Vector4;
  21657. invertUV?: boolean;
  21658. uvs?: Vector2[];
  21659. colors?: Color4[];
  21660. }): VertexData;
  21661. /**
  21662. * Creates the VertexData for a box
  21663. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21664. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21665. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21666. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21667. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21668. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21669. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21671. * * 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)
  21672. * * 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)
  21673. * @returns the VertexData of the box
  21674. */
  21675. static CreateBox(options: {
  21676. size?: number;
  21677. width?: number;
  21678. height?: number;
  21679. depth?: number;
  21680. faceUV?: Vector4[];
  21681. faceColors?: Color4[];
  21682. sideOrientation?: number;
  21683. frontUVs?: Vector4;
  21684. backUVs?: Vector4;
  21685. }): VertexData;
  21686. /**
  21687. * Creates the VertexData for a tiled box
  21688. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21689. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21690. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21691. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21693. * @returns the VertexData of the box
  21694. */
  21695. static CreateTiledBox(options: {
  21696. pattern?: number;
  21697. width?: number;
  21698. height?: number;
  21699. depth?: number;
  21700. tileSize?: number;
  21701. tileWidth?: number;
  21702. tileHeight?: number;
  21703. alignHorizontal?: number;
  21704. alignVertical?: number;
  21705. faceUV?: Vector4[];
  21706. faceColors?: Color4[];
  21707. sideOrientation?: number;
  21708. }): VertexData;
  21709. /**
  21710. * Creates the VertexData for a tiled plane
  21711. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21712. * * pattern a limited pattern arrangement depending on the number
  21713. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21714. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21715. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21717. * * 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)
  21718. * * 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)
  21719. * @returns the VertexData of the tiled plane
  21720. */
  21721. static CreateTiledPlane(options: {
  21722. pattern?: number;
  21723. tileSize?: number;
  21724. tileWidth?: number;
  21725. tileHeight?: number;
  21726. size?: number;
  21727. width?: number;
  21728. height?: number;
  21729. alignHorizontal?: number;
  21730. alignVertical?: number;
  21731. sideOrientation?: number;
  21732. frontUVs?: Vector4;
  21733. backUVs?: Vector4;
  21734. }): VertexData;
  21735. /**
  21736. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21737. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21738. * * segments sets the number of horizontal strips optional, default 32
  21739. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21740. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21741. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21742. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21743. * * 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
  21744. * * 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
  21745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21746. * * 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)
  21747. * * 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)
  21748. * @returns the VertexData of the ellipsoid
  21749. */
  21750. static CreateSphere(options: {
  21751. segments?: number;
  21752. diameter?: number;
  21753. diameterX?: number;
  21754. diameterY?: number;
  21755. diameterZ?: number;
  21756. arc?: number;
  21757. slice?: number;
  21758. sideOrientation?: number;
  21759. frontUVs?: Vector4;
  21760. backUVs?: Vector4;
  21761. }): VertexData;
  21762. /**
  21763. * Creates the VertexData for a cylinder, cone or prism
  21764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21765. * * height sets the height (y direction) of the cylinder, optional, default 2
  21766. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21767. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21768. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21769. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21770. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21771. * * 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
  21772. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21773. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21774. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21775. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21777. * * 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)
  21778. * * 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)
  21779. * @returns the VertexData of the cylinder, cone or prism
  21780. */
  21781. static CreateCylinder(options: {
  21782. height?: number;
  21783. diameterTop?: number;
  21784. diameterBottom?: number;
  21785. diameter?: number;
  21786. tessellation?: number;
  21787. subdivisions?: number;
  21788. arc?: number;
  21789. faceColors?: Color4[];
  21790. faceUV?: Vector4[];
  21791. hasRings?: boolean;
  21792. enclose?: boolean;
  21793. sideOrientation?: number;
  21794. frontUVs?: Vector4;
  21795. backUVs?: Vector4;
  21796. }): VertexData;
  21797. /**
  21798. * Creates the VertexData for a torus
  21799. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21800. * * diameter the diameter of the torus, optional default 1
  21801. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21802. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21804. * * 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)
  21805. * * 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)
  21806. * @returns the VertexData of the torus
  21807. */
  21808. static CreateTorus(options: {
  21809. diameter?: number;
  21810. thickness?: number;
  21811. tessellation?: number;
  21812. sideOrientation?: number;
  21813. frontUVs?: Vector4;
  21814. backUVs?: Vector4;
  21815. }): VertexData;
  21816. /**
  21817. * Creates the VertexData of the LineSystem
  21818. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21819. * - lines an array of lines, each line being an array of successive Vector3
  21820. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21821. * @returns the VertexData of the LineSystem
  21822. */
  21823. static CreateLineSystem(options: {
  21824. lines: Vector3[][];
  21825. colors?: Nullable<Color4[][]>;
  21826. }): VertexData;
  21827. /**
  21828. * Create the VertexData for a DashedLines
  21829. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21830. * - points an array successive Vector3
  21831. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21832. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21833. * - dashNb the intended total number of dashes, optional, default 200
  21834. * @returns the VertexData for the DashedLines
  21835. */
  21836. static CreateDashedLines(options: {
  21837. points: Vector3[];
  21838. dashSize?: number;
  21839. gapSize?: number;
  21840. dashNb?: number;
  21841. }): VertexData;
  21842. /**
  21843. * Creates the VertexData for a Ground
  21844. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21845. * - width the width (x direction) of the ground, optional, default 1
  21846. * - height the height (z direction) of the ground, optional, default 1
  21847. * - subdivisions the number of subdivisions per side, optional, default 1
  21848. * @returns the VertexData of the Ground
  21849. */
  21850. static CreateGround(options: {
  21851. width?: number;
  21852. height?: number;
  21853. subdivisions?: number;
  21854. subdivisionsX?: number;
  21855. subdivisionsY?: number;
  21856. }): VertexData;
  21857. /**
  21858. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21859. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21860. * * xmin the ground minimum X coordinate, optional, default -1
  21861. * * zmin the ground minimum Z coordinate, optional, default -1
  21862. * * xmax the ground maximum X coordinate, optional, default 1
  21863. * * zmax the ground maximum Z coordinate, optional, default 1
  21864. * * 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}
  21865. * * 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}
  21866. * @returns the VertexData of the TiledGround
  21867. */
  21868. static CreateTiledGround(options: {
  21869. xmin: number;
  21870. zmin: number;
  21871. xmax: number;
  21872. zmax: number;
  21873. subdivisions?: {
  21874. w: number;
  21875. h: number;
  21876. };
  21877. precision?: {
  21878. w: number;
  21879. h: number;
  21880. };
  21881. }): VertexData;
  21882. /**
  21883. * Creates the VertexData of the Ground designed from a heightmap
  21884. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21885. * * width the width (x direction) of the ground
  21886. * * height the height (z direction) of the ground
  21887. * * subdivisions the number of subdivisions per side
  21888. * * minHeight the minimum altitude on the ground, optional, default 0
  21889. * * maxHeight the maximum altitude on the ground, optional default 1
  21890. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21891. * * buffer the array holding the image color data
  21892. * * bufferWidth the width of image
  21893. * * bufferHeight the height of image
  21894. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21895. * @returns the VertexData of the Ground designed from a heightmap
  21896. */
  21897. static CreateGroundFromHeightMap(options: {
  21898. width: number;
  21899. height: number;
  21900. subdivisions: number;
  21901. minHeight: number;
  21902. maxHeight: number;
  21903. colorFilter: Color3;
  21904. buffer: Uint8Array;
  21905. bufferWidth: number;
  21906. bufferHeight: number;
  21907. alphaFilter: number;
  21908. }): VertexData;
  21909. /**
  21910. * Creates the VertexData for a Plane
  21911. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21912. * * size sets the width and height of the plane to the value of size, optional default 1
  21913. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21914. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21916. * * 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)
  21917. * * 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)
  21918. * @returns the VertexData of the box
  21919. */
  21920. static CreatePlane(options: {
  21921. size?: number;
  21922. width?: number;
  21923. height?: number;
  21924. sideOrientation?: number;
  21925. frontUVs?: Vector4;
  21926. backUVs?: Vector4;
  21927. }): VertexData;
  21928. /**
  21929. * Creates the VertexData of the Disc or regular Polygon
  21930. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21931. * * radius the radius of the disc, optional default 0.5
  21932. * * tessellation the number of polygon sides, optional, default 64
  21933. * * 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
  21934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21935. * * 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)
  21936. * * 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)
  21937. * @returns the VertexData of the box
  21938. */
  21939. static CreateDisc(options: {
  21940. radius?: number;
  21941. tessellation?: number;
  21942. arc?: number;
  21943. sideOrientation?: number;
  21944. frontUVs?: Vector4;
  21945. backUVs?: Vector4;
  21946. }): VertexData;
  21947. /**
  21948. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21949. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21950. * @param polygon a mesh built from polygonTriangulation.build()
  21951. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21952. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21953. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21954. * @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)
  21955. * @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)
  21956. * @returns the VertexData of the Polygon
  21957. */
  21958. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21959. /**
  21960. * Creates the VertexData of the IcoSphere
  21961. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21962. * * radius the radius of the IcoSphere, optional default 1
  21963. * * radiusX allows stretching in the x direction, optional, default radius
  21964. * * radiusY allows stretching in the y direction, optional, default radius
  21965. * * radiusZ allows stretching in the z direction, optional, default radius
  21966. * * flat when true creates a flat shaded mesh, optional, default true
  21967. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21969. * * 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)
  21970. * * 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)
  21971. * @returns the VertexData of the IcoSphere
  21972. */
  21973. static CreateIcoSphere(options: {
  21974. radius?: number;
  21975. radiusX?: number;
  21976. radiusY?: number;
  21977. radiusZ?: number;
  21978. flat?: boolean;
  21979. subdivisions?: number;
  21980. sideOrientation?: number;
  21981. frontUVs?: Vector4;
  21982. backUVs?: Vector4;
  21983. }): VertexData;
  21984. /**
  21985. * Creates the VertexData for a Polyhedron
  21986. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21987. * * type provided types are:
  21988. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21989. * * 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)
  21990. * * size the size of the IcoSphere, optional default 1
  21991. * * sizeX allows stretching in the x direction, optional, default size
  21992. * * sizeY allows stretching in the y direction, optional, default size
  21993. * * sizeZ allows stretching in the z direction, optional, default size
  21994. * * 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
  21995. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21996. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21997. * * flat when true creates a flat shaded mesh, optional, default true
  21998. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22000. * * 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)
  22001. * * 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)
  22002. * @returns the VertexData of the Polyhedron
  22003. */
  22004. static CreatePolyhedron(options: {
  22005. type?: number;
  22006. size?: number;
  22007. sizeX?: number;
  22008. sizeY?: number;
  22009. sizeZ?: number;
  22010. custom?: any;
  22011. faceUV?: Vector4[];
  22012. faceColors?: Color4[];
  22013. flat?: boolean;
  22014. sideOrientation?: number;
  22015. frontUVs?: Vector4;
  22016. backUVs?: Vector4;
  22017. }): VertexData;
  22018. /**
  22019. * Creates the VertexData for a TorusKnot
  22020. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22021. * * radius the radius of the torus knot, optional, default 2
  22022. * * tube the thickness of the tube, optional, default 0.5
  22023. * * radialSegments the number of sides on each tube segments, optional, default 32
  22024. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22025. * * p the number of windings around the z axis, optional, default 2
  22026. * * q the number of windings around the x axis, optional, default 3
  22027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22028. * * 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)
  22029. * * 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)
  22030. * @returns the VertexData of the Torus Knot
  22031. */
  22032. static CreateTorusKnot(options: {
  22033. radius?: number;
  22034. tube?: number;
  22035. radialSegments?: number;
  22036. tubularSegments?: number;
  22037. p?: number;
  22038. q?: number;
  22039. sideOrientation?: number;
  22040. frontUVs?: Vector4;
  22041. backUVs?: Vector4;
  22042. }): VertexData;
  22043. /**
  22044. * Compute normals for given positions and indices
  22045. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22046. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22047. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22048. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22049. * * facetNormals : optional array of facet normals (vector3)
  22050. * * facetPositions : optional array of facet positions (vector3)
  22051. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22052. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22053. * * bInfo : optional bounding info, required for facetPartitioning computation
  22054. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22055. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22056. * * useRightHandedSystem: optional boolean to for right handed system computation
  22057. * * depthSort : optional boolean to enable the facet depth sort computation
  22058. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22059. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22060. */
  22061. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22062. facetNormals?: any;
  22063. facetPositions?: any;
  22064. facetPartitioning?: any;
  22065. ratio?: number;
  22066. bInfo?: any;
  22067. bbSize?: Vector3;
  22068. subDiv?: any;
  22069. useRightHandedSystem?: boolean;
  22070. depthSort?: boolean;
  22071. distanceTo?: Vector3;
  22072. depthSortedFacets?: any;
  22073. }): void;
  22074. /** @hidden */
  22075. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22076. /**
  22077. * Applies VertexData created from the imported parameters to the geometry
  22078. * @param parsedVertexData the parsed data from an imported file
  22079. * @param geometry the geometry to apply the VertexData to
  22080. */
  22081. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22082. }
  22083. }
  22084. declare module BABYLON {
  22085. /**
  22086. * Defines a target to use with MorphTargetManager
  22087. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22088. */
  22089. export class MorphTarget implements IAnimatable {
  22090. /** defines the name of the target */
  22091. name: string;
  22092. /**
  22093. * Gets or sets the list of animations
  22094. */
  22095. animations: Animation[];
  22096. private _scene;
  22097. private _positions;
  22098. private _normals;
  22099. private _tangents;
  22100. private _uvs;
  22101. private _influence;
  22102. private _uniqueId;
  22103. /**
  22104. * Observable raised when the influence changes
  22105. */
  22106. onInfluenceChanged: Observable<boolean>;
  22107. /** @hidden */
  22108. _onDataLayoutChanged: Observable<void>;
  22109. /**
  22110. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22111. */
  22112. influence: number;
  22113. /**
  22114. * Gets or sets the id of the morph Target
  22115. */
  22116. id: string;
  22117. private _animationPropertiesOverride;
  22118. /**
  22119. * Gets or sets the animation properties override
  22120. */
  22121. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22122. /**
  22123. * Creates a new MorphTarget
  22124. * @param name defines the name of the target
  22125. * @param influence defines the influence to use
  22126. * @param scene defines the scene the morphtarget belongs to
  22127. */
  22128. constructor(
  22129. /** defines the name of the target */
  22130. name: string, influence?: number, scene?: Nullable<Scene>);
  22131. /**
  22132. * Gets the unique ID of this manager
  22133. */
  22134. readonly uniqueId: number;
  22135. /**
  22136. * Gets a boolean defining if the target contains position data
  22137. */
  22138. readonly hasPositions: boolean;
  22139. /**
  22140. * Gets a boolean defining if the target contains normal data
  22141. */
  22142. readonly hasNormals: boolean;
  22143. /**
  22144. * Gets a boolean defining if the target contains tangent data
  22145. */
  22146. readonly hasTangents: boolean;
  22147. /**
  22148. * Gets a boolean defining if the target contains texture coordinates data
  22149. */
  22150. readonly hasUVs: boolean;
  22151. /**
  22152. * Affects position data to this target
  22153. * @param data defines the position data to use
  22154. */
  22155. setPositions(data: Nullable<FloatArray>): void;
  22156. /**
  22157. * Gets the position data stored in this target
  22158. * @returns a FloatArray containing the position data (or null if not present)
  22159. */
  22160. getPositions(): Nullable<FloatArray>;
  22161. /**
  22162. * Affects normal data to this target
  22163. * @param data defines the normal data to use
  22164. */
  22165. setNormals(data: Nullable<FloatArray>): void;
  22166. /**
  22167. * Gets the normal data stored in this target
  22168. * @returns a FloatArray containing the normal data (or null if not present)
  22169. */
  22170. getNormals(): Nullable<FloatArray>;
  22171. /**
  22172. * Affects tangent data to this target
  22173. * @param data defines the tangent data to use
  22174. */
  22175. setTangents(data: Nullable<FloatArray>): void;
  22176. /**
  22177. * Gets the tangent data stored in this target
  22178. * @returns a FloatArray containing the tangent data (or null if not present)
  22179. */
  22180. getTangents(): Nullable<FloatArray>;
  22181. /**
  22182. * Affects texture coordinates data to this target
  22183. * @param data defines the texture coordinates data to use
  22184. */
  22185. setUVs(data: Nullable<FloatArray>): void;
  22186. /**
  22187. * Gets the texture coordinates data stored in this target
  22188. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22189. */
  22190. getUVs(): Nullable<FloatArray>;
  22191. /**
  22192. * Clone the current target
  22193. * @returns a new MorphTarget
  22194. */
  22195. clone(): MorphTarget;
  22196. /**
  22197. * Serializes the current target into a Serialization object
  22198. * @returns the serialized object
  22199. */
  22200. serialize(): any;
  22201. /**
  22202. * Returns the string "MorphTarget"
  22203. * @returns "MorphTarget"
  22204. */
  22205. getClassName(): string;
  22206. /**
  22207. * Creates a new target from serialized data
  22208. * @param serializationObject defines the serialized data to use
  22209. * @returns a new MorphTarget
  22210. */
  22211. static Parse(serializationObject: any): MorphTarget;
  22212. /**
  22213. * Creates a MorphTarget from mesh data
  22214. * @param mesh defines the source mesh
  22215. * @param name defines the name to use for the new target
  22216. * @param influence defines the influence to attach to the target
  22217. * @returns a new MorphTarget
  22218. */
  22219. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22220. }
  22221. }
  22222. declare module BABYLON {
  22223. /**
  22224. * This class is used to deform meshes using morphing between different targets
  22225. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22226. */
  22227. export class MorphTargetManager {
  22228. private _targets;
  22229. private _targetInfluenceChangedObservers;
  22230. private _targetDataLayoutChangedObservers;
  22231. private _activeTargets;
  22232. private _scene;
  22233. private _influences;
  22234. private _supportsNormals;
  22235. private _supportsTangents;
  22236. private _supportsUVs;
  22237. private _vertexCount;
  22238. private _uniqueId;
  22239. private _tempInfluences;
  22240. /**
  22241. * Gets or sets a boolean indicating if normals must be morphed
  22242. */
  22243. enableNormalMorphing: boolean;
  22244. /**
  22245. * Gets or sets a boolean indicating if tangents must be morphed
  22246. */
  22247. enableTangentMorphing: boolean;
  22248. /**
  22249. * Gets or sets a boolean indicating if UV must be morphed
  22250. */
  22251. enableUVMorphing: boolean;
  22252. /**
  22253. * Creates a new MorphTargetManager
  22254. * @param scene defines the current scene
  22255. */
  22256. constructor(scene?: Nullable<Scene>);
  22257. /**
  22258. * Gets the unique ID of this manager
  22259. */
  22260. readonly uniqueId: number;
  22261. /**
  22262. * Gets the number of vertices handled by this manager
  22263. */
  22264. readonly vertexCount: number;
  22265. /**
  22266. * Gets a boolean indicating if this manager supports morphing of normals
  22267. */
  22268. readonly supportsNormals: boolean;
  22269. /**
  22270. * Gets a boolean indicating if this manager supports morphing of tangents
  22271. */
  22272. readonly supportsTangents: boolean;
  22273. /**
  22274. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22275. */
  22276. readonly supportsUVs: boolean;
  22277. /**
  22278. * Gets the number of targets stored in this manager
  22279. */
  22280. readonly numTargets: number;
  22281. /**
  22282. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22283. */
  22284. readonly numInfluencers: number;
  22285. /**
  22286. * Gets the list of influences (one per target)
  22287. */
  22288. readonly influences: Float32Array;
  22289. /**
  22290. * Gets the active target at specified index. An active target is a target with an influence > 0
  22291. * @param index defines the index to check
  22292. * @returns the requested target
  22293. */
  22294. getActiveTarget(index: number): MorphTarget;
  22295. /**
  22296. * Gets the target at specified index
  22297. * @param index defines the index to check
  22298. * @returns the requested target
  22299. */
  22300. getTarget(index: number): MorphTarget;
  22301. /**
  22302. * Add a new target to this manager
  22303. * @param target defines the target to add
  22304. */
  22305. addTarget(target: MorphTarget): void;
  22306. /**
  22307. * Removes a target from the manager
  22308. * @param target defines the target to remove
  22309. */
  22310. removeTarget(target: MorphTarget): void;
  22311. /**
  22312. * Clone the current manager
  22313. * @returns a new MorphTargetManager
  22314. */
  22315. clone(): MorphTargetManager;
  22316. /**
  22317. * Serializes the current manager into a Serialization object
  22318. * @returns the serialized object
  22319. */
  22320. serialize(): any;
  22321. private _syncActiveTargets;
  22322. /**
  22323. * Syncrhonize the targets with all the meshes using this morph target manager
  22324. */
  22325. synchronize(): void;
  22326. /**
  22327. * Creates a new MorphTargetManager from serialized data
  22328. * @param serializationObject defines the serialized data
  22329. * @param scene defines the hosting scene
  22330. * @returns the new MorphTargetManager
  22331. */
  22332. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22333. }
  22334. }
  22335. declare module BABYLON {
  22336. /**
  22337. * Class used to represent a specific level of detail of a mesh
  22338. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22339. */
  22340. export class MeshLODLevel {
  22341. /** Defines the distance where this level should start being displayed */
  22342. distance: number;
  22343. /** Defines the mesh to use to render this level */
  22344. mesh: Nullable<Mesh>;
  22345. /**
  22346. * Creates a new LOD level
  22347. * @param distance defines the distance where this level should star being displayed
  22348. * @param mesh defines the mesh to use to render this level
  22349. */
  22350. constructor(
  22351. /** Defines the distance where this level should start being displayed */
  22352. distance: number,
  22353. /** Defines the mesh to use to render this level */
  22354. mesh: Nullable<Mesh>);
  22355. }
  22356. }
  22357. declare module BABYLON {
  22358. /**
  22359. * Mesh representing the gorund
  22360. */
  22361. export class GroundMesh extends Mesh {
  22362. /** If octree should be generated */
  22363. generateOctree: boolean;
  22364. private _heightQuads;
  22365. /** @hidden */
  22366. _subdivisionsX: number;
  22367. /** @hidden */
  22368. _subdivisionsY: number;
  22369. /** @hidden */
  22370. _width: number;
  22371. /** @hidden */
  22372. _height: number;
  22373. /** @hidden */
  22374. _minX: number;
  22375. /** @hidden */
  22376. _maxX: number;
  22377. /** @hidden */
  22378. _minZ: number;
  22379. /** @hidden */
  22380. _maxZ: number;
  22381. constructor(name: string, scene: Scene);
  22382. /**
  22383. * "GroundMesh"
  22384. * @returns "GroundMesh"
  22385. */
  22386. getClassName(): string;
  22387. /**
  22388. * The minimum of x and y subdivisions
  22389. */
  22390. readonly subdivisions: number;
  22391. /**
  22392. * X subdivisions
  22393. */
  22394. readonly subdivisionsX: number;
  22395. /**
  22396. * Y subdivisions
  22397. */
  22398. readonly subdivisionsY: number;
  22399. /**
  22400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22402. * @param chunksCount the number of subdivisions for x and y
  22403. * @param octreeBlocksSize (Default: 32)
  22404. */
  22405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22406. /**
  22407. * Returns a height (y) value in the Worl system :
  22408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22409. * @param x x coordinate
  22410. * @param z z coordinate
  22411. * @returns the ground y position if (x, z) are outside the ground surface.
  22412. */
  22413. getHeightAtCoordinates(x: number, z: number): number;
  22414. /**
  22415. * Returns a normalized vector (Vector3) orthogonal to the ground
  22416. * at the ground coordinates (x, z) expressed in the World system.
  22417. * @param x x coordinate
  22418. * @param z z coordinate
  22419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22420. */
  22421. getNormalAtCoordinates(x: number, z: number): Vector3;
  22422. /**
  22423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22424. * at the ground coordinates (x, z) expressed in the World system.
  22425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22426. * @param x x coordinate
  22427. * @param z z coordinate
  22428. * @param ref vector to store the result
  22429. * @returns the GroundMesh.
  22430. */
  22431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22432. /**
  22433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22434. * if the ground has been updated.
  22435. * This can be used in the render loop.
  22436. * @returns the GroundMesh.
  22437. */
  22438. updateCoordinateHeights(): GroundMesh;
  22439. private _getFacetAt;
  22440. private _initHeightQuads;
  22441. private _computeHeightQuads;
  22442. /**
  22443. * Serializes this ground mesh
  22444. * @param serializationObject object to write serialization to
  22445. */
  22446. serialize(serializationObject: any): void;
  22447. /**
  22448. * Parses a serialized ground mesh
  22449. * @param parsedMesh the serialized mesh
  22450. * @param scene the scene to create the ground mesh in
  22451. * @returns the created ground mesh
  22452. */
  22453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22454. }
  22455. }
  22456. declare module BABYLON {
  22457. /**
  22458. * Interface for Physics-Joint data
  22459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22460. */
  22461. export interface PhysicsJointData {
  22462. /**
  22463. * The main pivot of the joint
  22464. */
  22465. mainPivot?: Vector3;
  22466. /**
  22467. * The connected pivot of the joint
  22468. */
  22469. connectedPivot?: Vector3;
  22470. /**
  22471. * The main axis of the joint
  22472. */
  22473. mainAxis?: Vector3;
  22474. /**
  22475. * The connected axis of the joint
  22476. */
  22477. connectedAxis?: Vector3;
  22478. /**
  22479. * The collision of the joint
  22480. */
  22481. collision?: boolean;
  22482. /**
  22483. * Native Oimo/Cannon/Energy data
  22484. */
  22485. nativeParams?: any;
  22486. }
  22487. /**
  22488. * This is a holder class for the physics joint created by the physics plugin
  22489. * It holds a set of functions to control the underlying joint
  22490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22491. */
  22492. export class PhysicsJoint {
  22493. /**
  22494. * The type of the physics joint
  22495. */
  22496. type: number;
  22497. /**
  22498. * The data for the physics joint
  22499. */
  22500. jointData: PhysicsJointData;
  22501. private _physicsJoint;
  22502. protected _physicsPlugin: IPhysicsEnginePlugin;
  22503. /**
  22504. * Initializes the physics joint
  22505. * @param type The type of the physics joint
  22506. * @param jointData The data for the physics joint
  22507. */
  22508. constructor(
  22509. /**
  22510. * The type of the physics joint
  22511. */
  22512. type: number,
  22513. /**
  22514. * The data for the physics joint
  22515. */
  22516. jointData: PhysicsJointData);
  22517. /**
  22518. * Gets the physics joint
  22519. */
  22520. /**
  22521. * Sets the physics joint
  22522. */
  22523. physicsJoint: any;
  22524. /**
  22525. * Sets the physics plugin
  22526. */
  22527. physicsPlugin: IPhysicsEnginePlugin;
  22528. /**
  22529. * Execute a function that is physics-plugin specific.
  22530. * @param {Function} func the function that will be executed.
  22531. * It accepts two parameters: the physics world and the physics joint
  22532. */
  22533. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22534. /**
  22535. * Distance-Joint type
  22536. */
  22537. static DistanceJoint: number;
  22538. /**
  22539. * Hinge-Joint type
  22540. */
  22541. static HingeJoint: number;
  22542. /**
  22543. * Ball-and-Socket joint type
  22544. */
  22545. static BallAndSocketJoint: number;
  22546. /**
  22547. * Wheel-Joint type
  22548. */
  22549. static WheelJoint: number;
  22550. /**
  22551. * Slider-Joint type
  22552. */
  22553. static SliderJoint: number;
  22554. /**
  22555. * Prismatic-Joint type
  22556. */
  22557. static PrismaticJoint: number;
  22558. /**
  22559. * Universal-Joint type
  22560. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22561. */
  22562. static UniversalJoint: number;
  22563. /**
  22564. * Hinge-Joint 2 type
  22565. */
  22566. static Hinge2Joint: number;
  22567. /**
  22568. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22569. */
  22570. static PointToPointJoint: number;
  22571. /**
  22572. * Spring-Joint type
  22573. */
  22574. static SpringJoint: number;
  22575. /**
  22576. * Lock-Joint type
  22577. */
  22578. static LockJoint: number;
  22579. }
  22580. /**
  22581. * A class representing a physics distance joint
  22582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22583. */
  22584. export class DistanceJoint extends PhysicsJoint {
  22585. /**
  22586. *
  22587. * @param jointData The data for the Distance-Joint
  22588. */
  22589. constructor(jointData: DistanceJointData);
  22590. /**
  22591. * Update the predefined distance.
  22592. * @param maxDistance The maximum preferred distance
  22593. * @param minDistance The minimum preferred distance
  22594. */
  22595. updateDistance(maxDistance: number, minDistance?: number): void;
  22596. }
  22597. /**
  22598. * Represents a Motor-Enabled Joint
  22599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22600. */
  22601. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22602. /**
  22603. * Initializes the Motor-Enabled Joint
  22604. * @param type The type of the joint
  22605. * @param jointData The physica joint data for the joint
  22606. */
  22607. constructor(type: number, jointData: PhysicsJointData);
  22608. /**
  22609. * Set the motor values.
  22610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22611. * @param force the force to apply
  22612. * @param maxForce max force for this motor.
  22613. */
  22614. setMotor(force?: number, maxForce?: number): void;
  22615. /**
  22616. * Set the motor's limits.
  22617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22618. * @param upperLimit The upper limit of the motor
  22619. * @param lowerLimit The lower limit of the motor
  22620. */
  22621. setLimit(upperLimit: number, lowerLimit?: number): void;
  22622. }
  22623. /**
  22624. * This class represents a single physics Hinge-Joint
  22625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22626. */
  22627. export class HingeJoint extends MotorEnabledJoint {
  22628. /**
  22629. * Initializes the Hinge-Joint
  22630. * @param jointData The joint data for the Hinge-Joint
  22631. */
  22632. constructor(jointData: PhysicsJointData);
  22633. /**
  22634. * Set the motor values.
  22635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22636. * @param {number} force the force to apply
  22637. * @param {number} maxForce max force for this motor.
  22638. */
  22639. setMotor(force?: number, maxForce?: number): void;
  22640. /**
  22641. * Set the motor's limits.
  22642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22643. * @param upperLimit The upper limit of the motor
  22644. * @param lowerLimit The lower limit of the motor
  22645. */
  22646. setLimit(upperLimit: number, lowerLimit?: number): void;
  22647. }
  22648. /**
  22649. * This class represents a dual hinge physics joint (same as wheel joint)
  22650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22651. */
  22652. export class Hinge2Joint extends MotorEnabledJoint {
  22653. /**
  22654. * Initializes the Hinge2-Joint
  22655. * @param jointData The joint data for the Hinge2-Joint
  22656. */
  22657. constructor(jointData: PhysicsJointData);
  22658. /**
  22659. * Set the motor values.
  22660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22661. * @param {number} targetSpeed the speed the motor is to reach
  22662. * @param {number} maxForce max force for this motor.
  22663. * @param {motorIndex} the motor's index, 0 or 1.
  22664. */
  22665. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22666. /**
  22667. * Set the motor limits.
  22668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22669. * @param {number} upperLimit the upper limit
  22670. * @param {number} lowerLimit lower limit
  22671. * @param {motorIndex} the motor's index, 0 or 1.
  22672. */
  22673. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22674. }
  22675. /**
  22676. * Interface for a motor enabled joint
  22677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22678. */
  22679. export interface IMotorEnabledJoint {
  22680. /**
  22681. * Physics joint
  22682. */
  22683. physicsJoint: any;
  22684. /**
  22685. * Sets the motor of the motor-enabled joint
  22686. * @param force The force of the motor
  22687. * @param maxForce The maximum force of the motor
  22688. * @param motorIndex The index of the motor
  22689. */
  22690. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22691. /**
  22692. * Sets the limit of the motor
  22693. * @param upperLimit The upper limit of the motor
  22694. * @param lowerLimit The lower limit of the motor
  22695. * @param motorIndex The index of the motor
  22696. */
  22697. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22698. }
  22699. /**
  22700. * Joint data for a Distance-Joint
  22701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22702. */
  22703. export interface DistanceJointData extends PhysicsJointData {
  22704. /**
  22705. * Max distance the 2 joint objects can be apart
  22706. */
  22707. maxDistance: number;
  22708. }
  22709. /**
  22710. * Joint data from a spring joint
  22711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22712. */
  22713. export interface SpringJointData extends PhysicsJointData {
  22714. /**
  22715. * Length of the spring
  22716. */
  22717. length: number;
  22718. /**
  22719. * Stiffness of the spring
  22720. */
  22721. stiffness: number;
  22722. /**
  22723. * Damping of the spring
  22724. */
  22725. damping: number;
  22726. /** this callback will be called when applying the force to the impostors. */
  22727. forceApplicationCallback: () => void;
  22728. }
  22729. }
  22730. declare module BABYLON {
  22731. /**
  22732. * Holds the data for the raycast result
  22733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22734. */
  22735. export class PhysicsRaycastResult {
  22736. private _hasHit;
  22737. private _hitDistance;
  22738. private _hitNormalWorld;
  22739. private _hitPointWorld;
  22740. private _rayFromWorld;
  22741. private _rayToWorld;
  22742. /**
  22743. * Gets if there was a hit
  22744. */
  22745. readonly hasHit: boolean;
  22746. /**
  22747. * Gets the distance from the hit
  22748. */
  22749. readonly hitDistance: number;
  22750. /**
  22751. * Gets the hit normal/direction in the world
  22752. */
  22753. readonly hitNormalWorld: Vector3;
  22754. /**
  22755. * Gets the hit point in the world
  22756. */
  22757. readonly hitPointWorld: Vector3;
  22758. /**
  22759. * Gets the ray "start point" of the ray in the world
  22760. */
  22761. readonly rayFromWorld: Vector3;
  22762. /**
  22763. * Gets the ray "end point" of the ray in the world
  22764. */
  22765. readonly rayToWorld: Vector3;
  22766. /**
  22767. * Sets the hit data (normal & point in world space)
  22768. * @param hitNormalWorld defines the normal in world space
  22769. * @param hitPointWorld defines the point in world space
  22770. */
  22771. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22772. /**
  22773. * Sets the distance from the start point to the hit point
  22774. * @param distance
  22775. */
  22776. setHitDistance(distance: number): void;
  22777. /**
  22778. * Calculates the distance manually
  22779. */
  22780. calculateHitDistance(): void;
  22781. /**
  22782. * Resets all the values to default
  22783. * @param from The from point on world space
  22784. * @param to The to point on world space
  22785. */
  22786. reset(from?: Vector3, to?: Vector3): void;
  22787. }
  22788. /**
  22789. * Interface for the size containing width and height
  22790. */
  22791. interface IXYZ {
  22792. /**
  22793. * X
  22794. */
  22795. x: number;
  22796. /**
  22797. * Y
  22798. */
  22799. y: number;
  22800. /**
  22801. * Z
  22802. */
  22803. z: number;
  22804. }
  22805. }
  22806. declare module BABYLON {
  22807. /**
  22808. * Interface used to describe a physics joint
  22809. */
  22810. export interface PhysicsImpostorJoint {
  22811. /** Defines the main impostor to which the joint is linked */
  22812. mainImpostor: PhysicsImpostor;
  22813. /** Defines the impostor that is connected to the main impostor using this joint */
  22814. connectedImpostor: PhysicsImpostor;
  22815. /** Defines the joint itself */
  22816. joint: PhysicsJoint;
  22817. }
  22818. /** @hidden */
  22819. export interface IPhysicsEnginePlugin {
  22820. world: any;
  22821. name: string;
  22822. setGravity(gravity: Vector3): void;
  22823. setTimeStep(timeStep: number): void;
  22824. getTimeStep(): number;
  22825. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22826. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22827. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22829. removePhysicsBody(impostor: PhysicsImpostor): void;
  22830. generateJoint(joint: PhysicsImpostorJoint): void;
  22831. removeJoint(joint: PhysicsImpostorJoint): void;
  22832. isSupported(): boolean;
  22833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22835. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22837. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22840. getBodyMass(impostor: PhysicsImpostor): number;
  22841. getBodyFriction(impostor: PhysicsImpostor): number;
  22842. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22843. getBodyRestitution(impostor: PhysicsImpostor): number;
  22844. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22845. getBodyPressure?(impostor: PhysicsImpostor): number;
  22846. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22847. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22848. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22849. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22850. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22851. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22852. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22853. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22854. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22855. sleepBody(impostor: PhysicsImpostor): void;
  22856. wakeUpBody(impostor: PhysicsImpostor): void;
  22857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22859. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22860. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22861. getRadius(impostor: PhysicsImpostor): number;
  22862. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22863. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22864. dispose(): void;
  22865. }
  22866. /**
  22867. * Interface used to define a physics engine
  22868. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22869. */
  22870. export interface IPhysicsEngine {
  22871. /**
  22872. * Gets the gravity vector used by the simulation
  22873. */
  22874. gravity: Vector3;
  22875. /**
  22876. * Sets the gravity vector used by the simulation
  22877. * @param gravity defines the gravity vector to use
  22878. */
  22879. setGravity(gravity: Vector3): void;
  22880. /**
  22881. * Set the time step of the physics engine.
  22882. * Default is 1/60.
  22883. * To slow it down, enter 1/600 for example.
  22884. * To speed it up, 1/30
  22885. * @param newTimeStep the new timestep to apply to this world.
  22886. */
  22887. setTimeStep(newTimeStep: number): void;
  22888. /**
  22889. * Get the time step of the physics engine.
  22890. * @returns the current time step
  22891. */
  22892. getTimeStep(): number;
  22893. /**
  22894. * Release all resources
  22895. */
  22896. dispose(): void;
  22897. /**
  22898. * Gets the name of the current physics plugin
  22899. * @returns the name of the plugin
  22900. */
  22901. getPhysicsPluginName(): string;
  22902. /**
  22903. * Adding a new impostor for the impostor tracking.
  22904. * This will be done by the impostor itself.
  22905. * @param impostor the impostor to add
  22906. */
  22907. addImpostor(impostor: PhysicsImpostor): void;
  22908. /**
  22909. * Remove an impostor from the engine.
  22910. * This impostor and its mesh will not longer be updated by the physics engine.
  22911. * @param impostor the impostor to remove
  22912. */
  22913. removeImpostor(impostor: PhysicsImpostor): void;
  22914. /**
  22915. * Add a joint to the physics engine
  22916. * @param mainImpostor defines the main impostor to which the joint is added.
  22917. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22918. * @param joint defines the joint that will connect both impostors.
  22919. */
  22920. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22921. /**
  22922. * Removes a joint from the simulation
  22923. * @param mainImpostor defines the impostor used with the joint
  22924. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22925. * @param joint defines the joint to remove
  22926. */
  22927. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22928. /**
  22929. * Gets the current plugin used to run the simulation
  22930. * @returns current plugin
  22931. */
  22932. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22933. /**
  22934. * Gets the list of physic impostors
  22935. * @returns an array of PhysicsImpostor
  22936. */
  22937. getImpostors(): Array<PhysicsImpostor>;
  22938. /**
  22939. * Gets the impostor for a physics enabled object
  22940. * @param object defines the object impersonated by the impostor
  22941. * @returns the PhysicsImpostor or null if not found
  22942. */
  22943. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22944. /**
  22945. * Gets the impostor for a physics body object
  22946. * @param body defines physics body used by the impostor
  22947. * @returns the PhysicsImpostor or null if not found
  22948. */
  22949. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22950. /**
  22951. * Does a raycast in the physics world
  22952. * @param from when should the ray start?
  22953. * @param to when should the ray end?
  22954. * @returns PhysicsRaycastResult
  22955. */
  22956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22957. /**
  22958. * Called by the scene. No need to call it.
  22959. * @param delta defines the timespam between frames
  22960. */
  22961. _step(delta: number): void;
  22962. }
  22963. }
  22964. declare module BABYLON {
  22965. /**
  22966. * The interface for the physics imposter parameters
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export interface PhysicsImpostorParameters {
  22970. /**
  22971. * The mass of the physics imposter
  22972. */
  22973. mass: number;
  22974. /**
  22975. * The friction of the physics imposter
  22976. */
  22977. friction?: number;
  22978. /**
  22979. * The coefficient of restitution of the physics imposter
  22980. */
  22981. restitution?: number;
  22982. /**
  22983. * The native options of the physics imposter
  22984. */
  22985. nativeOptions?: any;
  22986. /**
  22987. * Specifies if the parent should be ignored
  22988. */
  22989. ignoreParent?: boolean;
  22990. /**
  22991. * Specifies if bi-directional transformations should be disabled
  22992. */
  22993. disableBidirectionalTransformation?: boolean;
  22994. /**
  22995. * The pressure inside the physics imposter, soft object only
  22996. */
  22997. pressure?: number;
  22998. /**
  22999. * The stiffness the physics imposter, soft object only
  23000. */
  23001. stiffness?: number;
  23002. /**
  23003. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23004. */
  23005. velocityIterations?: number;
  23006. /**
  23007. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23008. */
  23009. positionIterations?: number;
  23010. /**
  23011. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23012. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23013. * Add to fix multiple points
  23014. */
  23015. fixedPoints?: number;
  23016. /**
  23017. * The collision margin around a soft object
  23018. */
  23019. margin?: number;
  23020. /**
  23021. * The collision margin around a soft object
  23022. */
  23023. damping?: number;
  23024. /**
  23025. * The path for a rope based on an extrusion
  23026. */
  23027. path?: any;
  23028. /**
  23029. * The shape of an extrusion used for a rope based on an extrusion
  23030. */
  23031. shape?: any;
  23032. }
  23033. /**
  23034. * Interface for a physics-enabled object
  23035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23036. */
  23037. export interface IPhysicsEnabledObject {
  23038. /**
  23039. * The position of the physics-enabled object
  23040. */
  23041. position: Vector3;
  23042. /**
  23043. * The rotation of the physics-enabled object
  23044. */
  23045. rotationQuaternion: Nullable<Quaternion>;
  23046. /**
  23047. * The scale of the physics-enabled object
  23048. */
  23049. scaling: Vector3;
  23050. /**
  23051. * The rotation of the physics-enabled object
  23052. */
  23053. rotation?: Vector3;
  23054. /**
  23055. * The parent of the physics-enabled object
  23056. */
  23057. parent?: any;
  23058. /**
  23059. * The bounding info of the physics-enabled object
  23060. * @returns The bounding info of the physics-enabled object
  23061. */
  23062. getBoundingInfo(): BoundingInfo;
  23063. /**
  23064. * Computes the world matrix
  23065. * @param force Specifies if the world matrix should be computed by force
  23066. * @returns A world matrix
  23067. */
  23068. computeWorldMatrix(force: boolean): Matrix;
  23069. /**
  23070. * Gets the world matrix
  23071. * @returns A world matrix
  23072. */
  23073. getWorldMatrix?(): Matrix;
  23074. /**
  23075. * Gets the child meshes
  23076. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23077. * @returns An array of abstract meshes
  23078. */
  23079. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23080. /**
  23081. * Gets the vertex data
  23082. * @param kind The type of vertex data
  23083. * @returns A nullable array of numbers, or a float32 array
  23084. */
  23085. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23086. /**
  23087. * Gets the indices from the mesh
  23088. * @returns A nullable array of index arrays
  23089. */
  23090. getIndices?(): Nullable<IndicesArray>;
  23091. /**
  23092. * Gets the scene from the mesh
  23093. * @returns the indices array or null
  23094. */
  23095. getScene?(): Scene;
  23096. /**
  23097. * Gets the absolute position from the mesh
  23098. * @returns the absolute position
  23099. */
  23100. getAbsolutePosition(): Vector3;
  23101. /**
  23102. * Gets the absolute pivot point from the mesh
  23103. * @returns the absolute pivot point
  23104. */
  23105. getAbsolutePivotPoint(): Vector3;
  23106. /**
  23107. * Rotates the mesh
  23108. * @param axis The axis of rotation
  23109. * @param amount The amount of rotation
  23110. * @param space The space of the rotation
  23111. * @returns The rotation transform node
  23112. */
  23113. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23114. /**
  23115. * Translates the mesh
  23116. * @param axis The axis of translation
  23117. * @param distance The distance of translation
  23118. * @param space The space of the translation
  23119. * @returns The transform node
  23120. */
  23121. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23122. /**
  23123. * Sets the absolute position of the mesh
  23124. * @param absolutePosition The absolute position of the mesh
  23125. * @returns The transform node
  23126. */
  23127. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23128. /**
  23129. * Gets the class name of the mesh
  23130. * @returns The class name
  23131. */
  23132. getClassName(): string;
  23133. }
  23134. /**
  23135. * Represents a physics imposter
  23136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23137. */
  23138. export class PhysicsImpostor {
  23139. /**
  23140. * The physics-enabled object used as the physics imposter
  23141. */
  23142. object: IPhysicsEnabledObject;
  23143. /**
  23144. * The type of the physics imposter
  23145. */
  23146. type: number;
  23147. private _options;
  23148. private _scene?;
  23149. /**
  23150. * The default object size of the imposter
  23151. */
  23152. static DEFAULT_OBJECT_SIZE: Vector3;
  23153. /**
  23154. * The identity quaternion of the imposter
  23155. */
  23156. static IDENTITY_QUATERNION: Quaternion;
  23157. /** @hidden */
  23158. _pluginData: any;
  23159. private _physicsEngine;
  23160. private _physicsBody;
  23161. private _bodyUpdateRequired;
  23162. private _onBeforePhysicsStepCallbacks;
  23163. private _onAfterPhysicsStepCallbacks;
  23164. /** @hidden */
  23165. _onPhysicsCollideCallbacks: Array<{
  23166. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23167. otherImpostors: Array<PhysicsImpostor>;
  23168. }>;
  23169. private _deltaPosition;
  23170. private _deltaRotation;
  23171. private _deltaRotationConjugated;
  23172. /** @hidden */
  23173. _isFromLine: boolean;
  23174. private _parent;
  23175. private _isDisposed;
  23176. private static _tmpVecs;
  23177. private static _tmpQuat;
  23178. /**
  23179. * Specifies if the physics imposter is disposed
  23180. */
  23181. readonly isDisposed: boolean;
  23182. /**
  23183. * Gets the mass of the physics imposter
  23184. */
  23185. mass: number;
  23186. /**
  23187. * Gets the coefficient of friction
  23188. */
  23189. /**
  23190. * Sets the coefficient of friction
  23191. */
  23192. friction: number;
  23193. /**
  23194. * Gets the coefficient of restitution
  23195. */
  23196. /**
  23197. * Sets the coefficient of restitution
  23198. */
  23199. restitution: number;
  23200. /**
  23201. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23202. */
  23203. /**
  23204. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23205. */
  23206. pressure: number;
  23207. /**
  23208. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23209. */
  23210. /**
  23211. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23212. */
  23213. stiffness: number;
  23214. /**
  23215. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23216. */
  23217. /**
  23218. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23219. */
  23220. velocityIterations: number;
  23221. /**
  23222. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23223. */
  23224. /**
  23225. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23226. */
  23227. positionIterations: number;
  23228. /**
  23229. * The unique id of the physics imposter
  23230. * set by the physics engine when adding this impostor to the array
  23231. */
  23232. uniqueId: number;
  23233. /**
  23234. * @hidden
  23235. */
  23236. soft: boolean;
  23237. /**
  23238. * @hidden
  23239. */
  23240. segments: number;
  23241. private _joints;
  23242. /**
  23243. * Initializes the physics imposter
  23244. * @param object The physics-enabled object used as the physics imposter
  23245. * @param type The type of the physics imposter
  23246. * @param _options The options for the physics imposter
  23247. * @param _scene The Babylon scene
  23248. */
  23249. constructor(
  23250. /**
  23251. * The physics-enabled object used as the physics imposter
  23252. */
  23253. object: IPhysicsEnabledObject,
  23254. /**
  23255. * The type of the physics imposter
  23256. */
  23257. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23258. /**
  23259. * This function will completly initialize this impostor.
  23260. * It will create a new body - but only if this mesh has no parent.
  23261. * If it has, this impostor will not be used other than to define the impostor
  23262. * of the child mesh.
  23263. * @hidden
  23264. */
  23265. _init(): void;
  23266. private _getPhysicsParent;
  23267. /**
  23268. * Should a new body be generated.
  23269. * @returns boolean specifying if body initialization is required
  23270. */
  23271. isBodyInitRequired(): boolean;
  23272. /**
  23273. * Sets the updated scaling
  23274. * @param updated Specifies if the scaling is updated
  23275. */
  23276. setScalingUpdated(): void;
  23277. /**
  23278. * Force a regeneration of this or the parent's impostor's body.
  23279. * Use under cautious - This will remove all joints already implemented.
  23280. */
  23281. forceUpdate(): void;
  23282. /**
  23283. * Gets the body that holds this impostor. Either its own, or its parent.
  23284. */
  23285. /**
  23286. * Set the physics body. Used mainly by the physics engine/plugin
  23287. */
  23288. physicsBody: any;
  23289. /**
  23290. * Get the parent of the physics imposter
  23291. * @returns Physics imposter or null
  23292. */
  23293. /**
  23294. * Sets the parent of the physics imposter
  23295. */
  23296. parent: Nullable<PhysicsImpostor>;
  23297. /**
  23298. * Resets the update flags
  23299. */
  23300. resetUpdateFlags(): void;
  23301. /**
  23302. * Gets the object extend size
  23303. * @returns the object extend size
  23304. */
  23305. getObjectExtendSize(): Vector3;
  23306. /**
  23307. * Gets the object center
  23308. * @returns The object center
  23309. */
  23310. getObjectCenter(): Vector3;
  23311. /**
  23312. * Get a specific parametes from the options parameter
  23313. * @param paramName The object parameter name
  23314. * @returns The object parameter
  23315. */
  23316. getParam(paramName: string): any;
  23317. /**
  23318. * Sets a specific parameter in the options given to the physics plugin
  23319. * @param paramName The parameter name
  23320. * @param value The value of the parameter
  23321. */
  23322. setParam(paramName: string, value: number): void;
  23323. /**
  23324. * Specifically change the body's mass option. Won't recreate the physics body object
  23325. * @param mass The mass of the physics imposter
  23326. */
  23327. setMass(mass: number): void;
  23328. /**
  23329. * Gets the linear velocity
  23330. * @returns linear velocity or null
  23331. */
  23332. getLinearVelocity(): Nullable<Vector3>;
  23333. /**
  23334. * Sets the linear velocity
  23335. * @param velocity linear velocity or null
  23336. */
  23337. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23338. /**
  23339. * Gets the angular velocity
  23340. * @returns angular velocity or null
  23341. */
  23342. getAngularVelocity(): Nullable<Vector3>;
  23343. /**
  23344. * Sets the angular velocity
  23345. * @param velocity The velocity or null
  23346. */
  23347. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23348. /**
  23349. * Execute a function with the physics plugin native code
  23350. * Provide a function the will have two variables - the world object and the physics body object
  23351. * @param func The function to execute with the physics plugin native code
  23352. */
  23353. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23354. /**
  23355. * Register a function that will be executed before the physics world is stepping forward
  23356. * @param func The function to execute before the physics world is stepped forward
  23357. */
  23358. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23359. /**
  23360. * Unregister a function that will be executed before the physics world is stepping forward
  23361. * @param func The function to execute before the physics world is stepped forward
  23362. */
  23363. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23364. /**
  23365. * Register a function that will be executed after the physics step
  23366. * @param func The function to execute after physics step
  23367. */
  23368. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23369. /**
  23370. * Unregisters a function that will be executed after the physics step
  23371. * @param func The function to execute after physics step
  23372. */
  23373. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23374. /**
  23375. * register a function that will be executed when this impostor collides against a different body
  23376. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23377. * @param func Callback that is executed on collision
  23378. */
  23379. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23380. /**
  23381. * Unregisters the physics imposter on contact
  23382. * @param collideAgainst The physics object to collide against
  23383. * @param func Callback to execute on collision
  23384. */
  23385. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23386. private _tmpQuat;
  23387. private _tmpQuat2;
  23388. /**
  23389. * Get the parent rotation
  23390. * @returns The parent rotation
  23391. */
  23392. getParentsRotation(): Quaternion;
  23393. /**
  23394. * this function is executed by the physics engine.
  23395. */
  23396. beforeStep: () => void;
  23397. /**
  23398. * this function is executed by the physics engine
  23399. */
  23400. afterStep: () => void;
  23401. /**
  23402. * Legacy collision detection event support
  23403. */
  23404. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23405. /**
  23406. * event and body object due to cannon's event-based architecture.
  23407. */
  23408. onCollide: (e: {
  23409. body: any;
  23410. }) => void;
  23411. /**
  23412. * Apply a force
  23413. * @param force The force to apply
  23414. * @param contactPoint The contact point for the force
  23415. * @returns The physics imposter
  23416. */
  23417. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23418. /**
  23419. * Apply an impulse
  23420. * @param force The impulse force
  23421. * @param contactPoint The contact point for the impulse force
  23422. * @returns The physics imposter
  23423. */
  23424. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23425. /**
  23426. * A help function to create a joint
  23427. * @param otherImpostor A physics imposter used to create a joint
  23428. * @param jointType The type of joint
  23429. * @param jointData The data for the joint
  23430. * @returns The physics imposter
  23431. */
  23432. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23433. /**
  23434. * Add a joint to this impostor with a different impostor
  23435. * @param otherImpostor A physics imposter used to add a joint
  23436. * @param joint The joint to add
  23437. * @returns The physics imposter
  23438. */
  23439. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23440. /**
  23441. * Add an anchor to a cloth impostor
  23442. * @param otherImpostor rigid impostor to anchor to
  23443. * @param width ratio across width from 0 to 1
  23444. * @param height ratio up height from 0 to 1
  23445. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23446. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23447. * @returns impostor the soft imposter
  23448. */
  23449. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23450. /**
  23451. * Add a hook to a rope impostor
  23452. * @param otherImpostor rigid impostor to anchor to
  23453. * @param length ratio across rope from 0 to 1
  23454. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23455. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23456. * @returns impostor the rope imposter
  23457. */
  23458. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23459. /**
  23460. * Will keep this body still, in a sleep mode.
  23461. * @returns the physics imposter
  23462. */
  23463. sleep(): PhysicsImpostor;
  23464. /**
  23465. * Wake the body up.
  23466. * @returns The physics imposter
  23467. */
  23468. wakeUp(): PhysicsImpostor;
  23469. /**
  23470. * Clones the physics imposter
  23471. * @param newObject The physics imposter clones to this physics-enabled object
  23472. * @returns A nullable physics imposter
  23473. */
  23474. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23475. /**
  23476. * Disposes the physics imposter
  23477. */
  23478. dispose(): void;
  23479. /**
  23480. * Sets the delta position
  23481. * @param position The delta position amount
  23482. */
  23483. setDeltaPosition(position: Vector3): void;
  23484. /**
  23485. * Sets the delta rotation
  23486. * @param rotation The delta rotation amount
  23487. */
  23488. setDeltaRotation(rotation: Quaternion): void;
  23489. /**
  23490. * Gets the box size of the physics imposter and stores the result in the input parameter
  23491. * @param result Stores the box size
  23492. * @returns The physics imposter
  23493. */
  23494. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23495. /**
  23496. * Gets the radius of the physics imposter
  23497. * @returns Radius of the physics imposter
  23498. */
  23499. getRadius(): number;
  23500. /**
  23501. * Sync a bone with this impostor
  23502. * @param bone The bone to sync to the impostor.
  23503. * @param boneMesh The mesh that the bone is influencing.
  23504. * @param jointPivot The pivot of the joint / bone in local space.
  23505. * @param distToJoint Optional distance from the impostor to the joint.
  23506. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23507. */
  23508. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23509. /**
  23510. * Sync impostor to a bone
  23511. * @param bone The bone that the impostor will be synced to.
  23512. * @param boneMesh The mesh that the bone is influencing.
  23513. * @param jointPivot The pivot of the joint / bone in local space.
  23514. * @param distToJoint Optional distance from the impostor to the joint.
  23515. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23516. * @param boneAxis Optional vector3 axis the bone is aligned with
  23517. */
  23518. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23519. /**
  23520. * No-Imposter type
  23521. */
  23522. static NoImpostor: number;
  23523. /**
  23524. * Sphere-Imposter type
  23525. */
  23526. static SphereImpostor: number;
  23527. /**
  23528. * Box-Imposter type
  23529. */
  23530. static BoxImpostor: number;
  23531. /**
  23532. * Plane-Imposter type
  23533. */
  23534. static PlaneImpostor: number;
  23535. /**
  23536. * Mesh-imposter type
  23537. */
  23538. static MeshImpostor: number;
  23539. /**
  23540. * Capsule-Impostor type (Ammo.js plugin only)
  23541. */
  23542. static CapsuleImpostor: number;
  23543. /**
  23544. * Cylinder-Imposter type
  23545. */
  23546. static CylinderImpostor: number;
  23547. /**
  23548. * Particle-Imposter type
  23549. */
  23550. static ParticleImpostor: number;
  23551. /**
  23552. * Heightmap-Imposter type
  23553. */
  23554. static HeightmapImpostor: number;
  23555. /**
  23556. * ConvexHull-Impostor type (Ammo.js plugin only)
  23557. */
  23558. static ConvexHullImpostor: number;
  23559. /**
  23560. * Rope-Imposter type
  23561. */
  23562. static RopeImpostor: number;
  23563. /**
  23564. * Cloth-Imposter type
  23565. */
  23566. static ClothImpostor: number;
  23567. /**
  23568. * Softbody-Imposter type
  23569. */
  23570. static SoftbodyImpostor: number;
  23571. }
  23572. }
  23573. declare module BABYLON {
  23574. /**
  23575. * @hidden
  23576. **/
  23577. export class _CreationDataStorage {
  23578. closePath?: boolean;
  23579. closeArray?: boolean;
  23580. idx: number[];
  23581. dashSize: number;
  23582. gapSize: number;
  23583. path3D: Path3D;
  23584. pathArray: Vector3[][];
  23585. arc: number;
  23586. radius: number;
  23587. cap: number;
  23588. tessellation: number;
  23589. }
  23590. /**
  23591. * @hidden
  23592. **/
  23593. class _InstanceDataStorage {
  23594. visibleInstances: any;
  23595. batchCache: _InstancesBatch;
  23596. instancesBufferSize: number;
  23597. instancesBuffer: Nullable<Buffer>;
  23598. instancesData: Float32Array;
  23599. overridenInstanceCount: number;
  23600. isFrozen: boolean;
  23601. previousBatch: Nullable<_InstancesBatch>;
  23602. hardwareInstancedRendering: boolean;
  23603. sideOrientation: number;
  23604. }
  23605. /**
  23606. * @hidden
  23607. **/
  23608. export class _InstancesBatch {
  23609. mustReturn: boolean;
  23610. visibleInstances: Nullable<InstancedMesh[]>[];
  23611. renderSelf: boolean[];
  23612. hardwareInstancedRendering: boolean[];
  23613. }
  23614. /**
  23615. * Class used to represent renderable models
  23616. */
  23617. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23618. /**
  23619. * Mesh side orientation : usually the external or front surface
  23620. */
  23621. static readonly FRONTSIDE: number;
  23622. /**
  23623. * Mesh side orientation : usually the internal or back surface
  23624. */
  23625. static readonly BACKSIDE: number;
  23626. /**
  23627. * Mesh side orientation : both internal and external or front and back surfaces
  23628. */
  23629. static readonly DOUBLESIDE: number;
  23630. /**
  23631. * Mesh side orientation : by default, `FRONTSIDE`
  23632. */
  23633. static readonly DEFAULTSIDE: number;
  23634. /**
  23635. * Mesh cap setting : no cap
  23636. */
  23637. static readonly NO_CAP: number;
  23638. /**
  23639. * Mesh cap setting : one cap at the beginning of the mesh
  23640. */
  23641. static readonly CAP_START: number;
  23642. /**
  23643. * Mesh cap setting : one cap at the end of the mesh
  23644. */
  23645. static readonly CAP_END: number;
  23646. /**
  23647. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23648. */
  23649. static readonly CAP_ALL: number;
  23650. /**
  23651. * Mesh pattern setting : no flip or rotate
  23652. */
  23653. static readonly NO_FLIP: number;
  23654. /**
  23655. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23656. */
  23657. static readonly FLIP_TILE: number;
  23658. /**
  23659. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23660. */
  23661. static readonly ROTATE_TILE: number;
  23662. /**
  23663. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23664. */
  23665. static readonly FLIP_ROW: number;
  23666. /**
  23667. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23668. */
  23669. static readonly ROTATE_ROW: number;
  23670. /**
  23671. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23672. */
  23673. static readonly FLIP_N_ROTATE_TILE: number;
  23674. /**
  23675. * Mesh pattern setting : rotate pattern and rotate
  23676. */
  23677. static readonly FLIP_N_ROTATE_ROW: number;
  23678. /**
  23679. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23680. */
  23681. static readonly CENTER: number;
  23682. /**
  23683. * Mesh tile positioning : part tiles on left
  23684. */
  23685. static readonly LEFT: number;
  23686. /**
  23687. * Mesh tile positioning : part tiles on right
  23688. */
  23689. static readonly RIGHT: number;
  23690. /**
  23691. * Mesh tile positioning : part tiles on top
  23692. */
  23693. static readonly TOP: number;
  23694. /**
  23695. * Mesh tile positioning : part tiles on bottom
  23696. */
  23697. static readonly BOTTOM: number;
  23698. /**
  23699. * Gets the default side orientation.
  23700. * @param orientation the orientation to value to attempt to get
  23701. * @returns the default orientation
  23702. * @hidden
  23703. */
  23704. static _GetDefaultSideOrientation(orientation?: number): number;
  23705. private _internalMeshDataInfo;
  23706. /**
  23707. * An event triggered before rendering the mesh
  23708. */
  23709. readonly onBeforeRenderObservable: Observable<Mesh>;
  23710. /**
  23711. * An event triggered before binding the mesh
  23712. */
  23713. readonly onBeforeBindObservable: Observable<Mesh>;
  23714. /**
  23715. * An event triggered after rendering the mesh
  23716. */
  23717. readonly onAfterRenderObservable: Observable<Mesh>;
  23718. /**
  23719. * An event triggered before drawing the mesh
  23720. */
  23721. readonly onBeforeDrawObservable: Observable<Mesh>;
  23722. private _onBeforeDrawObserver;
  23723. /**
  23724. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23725. */
  23726. onBeforeDraw: () => void;
  23727. readonly hasInstances: boolean;
  23728. /**
  23729. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23730. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23731. */
  23732. delayLoadState: number;
  23733. /**
  23734. * Gets the list of instances created from this mesh
  23735. * it is not supposed to be modified manually.
  23736. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23737. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23738. */
  23739. instances: InstancedMesh[];
  23740. /**
  23741. * Gets the file containing delay loading data for this mesh
  23742. */
  23743. delayLoadingFile: string;
  23744. /** @hidden */
  23745. _binaryInfo: any;
  23746. /**
  23747. * User defined function used to change how LOD level selection is done
  23748. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23749. */
  23750. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23751. /**
  23752. * Gets or sets the morph target manager
  23753. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23754. */
  23755. morphTargetManager: Nullable<MorphTargetManager>;
  23756. /** @hidden */
  23757. _creationDataStorage: Nullable<_CreationDataStorage>;
  23758. /** @hidden */
  23759. _geometry: Nullable<Geometry>;
  23760. /** @hidden */
  23761. _delayInfo: Array<string>;
  23762. /** @hidden */
  23763. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23764. /** @hidden */
  23765. _instanceDataStorage: _InstanceDataStorage;
  23766. private _effectiveMaterial;
  23767. /** @hidden */
  23768. _shouldGenerateFlatShading: boolean;
  23769. /** @hidden */
  23770. _originalBuilderSideOrientation: number;
  23771. /**
  23772. * Use this property to change the original side orientation defined at construction time
  23773. */
  23774. overrideMaterialSideOrientation: Nullable<number>;
  23775. /**
  23776. * Gets the source mesh (the one used to clone this one from)
  23777. */
  23778. readonly source: Nullable<Mesh>;
  23779. /**
  23780. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23781. */
  23782. isUnIndexed: boolean;
  23783. /**
  23784. * @constructor
  23785. * @param name The value used by scene.getMeshByName() to do a lookup.
  23786. * @param scene The scene to add this mesh to.
  23787. * @param parent The parent of this mesh, if it has one
  23788. * @param source An optional Mesh from which geometry is shared, cloned.
  23789. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23790. * When false, achieved by calling a clone(), also passing False.
  23791. * This will make creation of children, recursive.
  23792. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23793. */
  23794. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23795. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23796. doNotInstantiate: boolean;
  23797. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23798. /**
  23799. * Gets the class name
  23800. * @returns the string "Mesh".
  23801. */
  23802. getClassName(): string;
  23803. /** @hidden */
  23804. readonly _isMesh: boolean;
  23805. /**
  23806. * Returns a description of this mesh
  23807. * @param fullDetails define if full details about this mesh must be used
  23808. * @returns a descriptive string representing this mesh
  23809. */
  23810. toString(fullDetails?: boolean): string;
  23811. /** @hidden */
  23812. _unBindEffect(): void;
  23813. /**
  23814. * Gets a boolean indicating if this mesh has LOD
  23815. */
  23816. readonly hasLODLevels: boolean;
  23817. /**
  23818. * Gets the list of MeshLODLevel associated with the current mesh
  23819. * @returns an array of MeshLODLevel
  23820. */
  23821. getLODLevels(): MeshLODLevel[];
  23822. private _sortLODLevels;
  23823. /**
  23824. * Add a mesh as LOD level triggered at the given distance.
  23825. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23826. * @param distance The distance from the center of the object to show this level
  23827. * @param mesh The mesh to be added as LOD level (can be null)
  23828. * @return This mesh (for chaining)
  23829. */
  23830. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23831. /**
  23832. * Returns the LOD level mesh at the passed distance or null if not found.
  23833. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23834. * @param distance The distance from the center of the object to show this level
  23835. * @returns a Mesh or `null`
  23836. */
  23837. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23838. /**
  23839. * Remove a mesh from the LOD array
  23840. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23841. * @param mesh defines the mesh to be removed
  23842. * @return This mesh (for chaining)
  23843. */
  23844. removeLODLevel(mesh: Mesh): Mesh;
  23845. /**
  23846. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23847. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23848. * @param camera defines the camera to use to compute distance
  23849. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23850. * @return This mesh (for chaining)
  23851. */
  23852. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23853. /**
  23854. * Gets the mesh internal Geometry object
  23855. */
  23856. readonly geometry: Nullable<Geometry>;
  23857. /**
  23858. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23859. * @returns the total number of vertices
  23860. */
  23861. getTotalVertices(): number;
  23862. /**
  23863. * Returns the content of an associated vertex buffer
  23864. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23865. * - VertexBuffer.PositionKind
  23866. * - VertexBuffer.UVKind
  23867. * - VertexBuffer.UV2Kind
  23868. * - VertexBuffer.UV3Kind
  23869. * - VertexBuffer.UV4Kind
  23870. * - VertexBuffer.UV5Kind
  23871. * - VertexBuffer.UV6Kind
  23872. * - VertexBuffer.ColorKind
  23873. * - VertexBuffer.MatricesIndicesKind
  23874. * - VertexBuffer.MatricesIndicesExtraKind
  23875. * - VertexBuffer.MatricesWeightsKind
  23876. * - VertexBuffer.MatricesWeightsExtraKind
  23877. * @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
  23878. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23879. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23880. */
  23881. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23882. /**
  23883. * Returns the mesh VertexBuffer object from the requested `kind`
  23884. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23885. * - VertexBuffer.PositionKind
  23886. * - VertexBuffer.NormalKind
  23887. * - VertexBuffer.UVKind
  23888. * - VertexBuffer.UV2Kind
  23889. * - VertexBuffer.UV3Kind
  23890. * - VertexBuffer.UV4Kind
  23891. * - VertexBuffer.UV5Kind
  23892. * - VertexBuffer.UV6Kind
  23893. * - VertexBuffer.ColorKind
  23894. * - VertexBuffer.MatricesIndicesKind
  23895. * - VertexBuffer.MatricesIndicesExtraKind
  23896. * - VertexBuffer.MatricesWeightsKind
  23897. * - VertexBuffer.MatricesWeightsExtraKind
  23898. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23899. */
  23900. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23901. /**
  23902. * Tests if a specific vertex buffer is associated with this mesh
  23903. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23904. * - VertexBuffer.PositionKind
  23905. * - VertexBuffer.NormalKind
  23906. * - VertexBuffer.UVKind
  23907. * - VertexBuffer.UV2Kind
  23908. * - VertexBuffer.UV3Kind
  23909. * - VertexBuffer.UV4Kind
  23910. * - VertexBuffer.UV5Kind
  23911. * - VertexBuffer.UV6Kind
  23912. * - VertexBuffer.ColorKind
  23913. * - VertexBuffer.MatricesIndicesKind
  23914. * - VertexBuffer.MatricesIndicesExtraKind
  23915. * - VertexBuffer.MatricesWeightsKind
  23916. * - VertexBuffer.MatricesWeightsExtraKind
  23917. * @returns a boolean
  23918. */
  23919. isVerticesDataPresent(kind: string): boolean;
  23920. /**
  23921. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23922. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23923. * - VertexBuffer.PositionKind
  23924. * - VertexBuffer.UVKind
  23925. * - VertexBuffer.UV2Kind
  23926. * - VertexBuffer.UV3Kind
  23927. * - VertexBuffer.UV4Kind
  23928. * - VertexBuffer.UV5Kind
  23929. * - VertexBuffer.UV6Kind
  23930. * - VertexBuffer.ColorKind
  23931. * - VertexBuffer.MatricesIndicesKind
  23932. * - VertexBuffer.MatricesIndicesExtraKind
  23933. * - VertexBuffer.MatricesWeightsKind
  23934. * - VertexBuffer.MatricesWeightsExtraKind
  23935. * @returns a boolean
  23936. */
  23937. isVertexBufferUpdatable(kind: string): boolean;
  23938. /**
  23939. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23940. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23941. * - VertexBuffer.PositionKind
  23942. * - VertexBuffer.NormalKind
  23943. * - VertexBuffer.UVKind
  23944. * - VertexBuffer.UV2Kind
  23945. * - VertexBuffer.UV3Kind
  23946. * - VertexBuffer.UV4Kind
  23947. * - VertexBuffer.UV5Kind
  23948. * - VertexBuffer.UV6Kind
  23949. * - VertexBuffer.ColorKind
  23950. * - VertexBuffer.MatricesIndicesKind
  23951. * - VertexBuffer.MatricesIndicesExtraKind
  23952. * - VertexBuffer.MatricesWeightsKind
  23953. * - VertexBuffer.MatricesWeightsExtraKind
  23954. * @returns an array of strings
  23955. */
  23956. getVerticesDataKinds(): string[];
  23957. /**
  23958. * Returns a positive integer : the total number of indices in this mesh geometry.
  23959. * @returns the numner of indices or zero if the mesh has no geometry.
  23960. */
  23961. getTotalIndices(): number;
  23962. /**
  23963. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23964. * @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.
  23965. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23966. * @returns the indices array or an empty array if the mesh has no geometry
  23967. */
  23968. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23969. readonly isBlocked: boolean;
  23970. /**
  23971. * Determine if the current mesh is ready to be rendered
  23972. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23973. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23974. * @returns true if all associated assets are ready (material, textures, shaders)
  23975. */
  23976. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23977. /**
  23978. * 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.
  23979. */
  23980. readonly areNormalsFrozen: boolean;
  23981. /**
  23982. * 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.
  23983. * @returns the current mesh
  23984. */
  23985. freezeNormals(): Mesh;
  23986. /**
  23987. * 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
  23988. * @returns the current mesh
  23989. */
  23990. unfreezeNormals(): Mesh;
  23991. /**
  23992. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23993. */
  23994. overridenInstanceCount: number;
  23995. /** @hidden */
  23996. _preActivate(): Mesh;
  23997. /** @hidden */
  23998. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23999. /** @hidden */
  24000. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24001. /**
  24002. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24003. * This means the mesh underlying bounding box and sphere are recomputed.
  24004. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24005. * @returns the current mesh
  24006. */
  24007. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24008. /** @hidden */
  24009. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24010. /**
  24011. * This function will subdivide the mesh into multiple submeshes
  24012. * @param count defines the expected number of submeshes
  24013. */
  24014. subdivide(count: number): void;
  24015. /**
  24016. * Copy a FloatArray into a specific associated vertex buffer
  24017. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24018. * - VertexBuffer.PositionKind
  24019. * - VertexBuffer.UVKind
  24020. * - VertexBuffer.UV2Kind
  24021. * - VertexBuffer.UV3Kind
  24022. * - VertexBuffer.UV4Kind
  24023. * - VertexBuffer.UV5Kind
  24024. * - VertexBuffer.UV6Kind
  24025. * - VertexBuffer.ColorKind
  24026. * - VertexBuffer.MatricesIndicesKind
  24027. * - VertexBuffer.MatricesIndicesExtraKind
  24028. * - VertexBuffer.MatricesWeightsKind
  24029. * - VertexBuffer.MatricesWeightsExtraKind
  24030. * @param data defines the data source
  24031. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24032. * @param stride defines the data stride size (can be null)
  24033. * @returns the current mesh
  24034. */
  24035. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24036. /**
  24037. * Delete a vertex buffer associated with this mesh
  24038. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24039. * - VertexBuffer.PositionKind
  24040. * - VertexBuffer.UVKind
  24041. * - VertexBuffer.UV2Kind
  24042. * - VertexBuffer.UV3Kind
  24043. * - VertexBuffer.UV4Kind
  24044. * - VertexBuffer.UV5Kind
  24045. * - VertexBuffer.UV6Kind
  24046. * - VertexBuffer.ColorKind
  24047. * - VertexBuffer.MatricesIndicesKind
  24048. * - VertexBuffer.MatricesIndicesExtraKind
  24049. * - VertexBuffer.MatricesWeightsKind
  24050. * - VertexBuffer.MatricesWeightsExtraKind
  24051. */
  24052. removeVerticesData(kind: string): void;
  24053. /**
  24054. * Flags an associated vertex buffer as updatable
  24055. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24056. * - VertexBuffer.PositionKind
  24057. * - VertexBuffer.UVKind
  24058. * - VertexBuffer.UV2Kind
  24059. * - VertexBuffer.UV3Kind
  24060. * - VertexBuffer.UV4Kind
  24061. * - VertexBuffer.UV5Kind
  24062. * - VertexBuffer.UV6Kind
  24063. * - VertexBuffer.ColorKind
  24064. * - VertexBuffer.MatricesIndicesKind
  24065. * - VertexBuffer.MatricesIndicesExtraKind
  24066. * - VertexBuffer.MatricesWeightsKind
  24067. * - VertexBuffer.MatricesWeightsExtraKind
  24068. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24069. */
  24070. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24071. /**
  24072. * Sets the mesh global Vertex Buffer
  24073. * @param buffer defines the buffer to use
  24074. * @returns the current mesh
  24075. */
  24076. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24077. /**
  24078. * Update a specific associated vertex buffer
  24079. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24080. * - VertexBuffer.PositionKind
  24081. * - VertexBuffer.UVKind
  24082. * - VertexBuffer.UV2Kind
  24083. * - VertexBuffer.UV3Kind
  24084. * - VertexBuffer.UV4Kind
  24085. * - VertexBuffer.UV5Kind
  24086. * - VertexBuffer.UV6Kind
  24087. * - VertexBuffer.ColorKind
  24088. * - VertexBuffer.MatricesIndicesKind
  24089. * - VertexBuffer.MatricesIndicesExtraKind
  24090. * - VertexBuffer.MatricesWeightsKind
  24091. * - VertexBuffer.MatricesWeightsExtraKind
  24092. * @param data defines the data source
  24093. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24094. * @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)
  24095. * @returns the current mesh
  24096. */
  24097. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24098. /**
  24099. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24100. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24101. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24102. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24103. * @returns the current mesh
  24104. */
  24105. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24106. /**
  24107. * Creates a un-shared specific occurence of the geometry for the mesh.
  24108. * @returns the current mesh
  24109. */
  24110. makeGeometryUnique(): Mesh;
  24111. /**
  24112. * Set the index buffer of this mesh
  24113. * @param indices defines the source data
  24114. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24115. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24116. * @returns the current mesh
  24117. */
  24118. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24119. /**
  24120. * Update the current index buffer
  24121. * @param indices defines the source data
  24122. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24123. * @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)
  24124. * @returns the current mesh
  24125. */
  24126. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24127. /**
  24128. * Invert the geometry to move from a right handed system to a left handed one.
  24129. * @returns the current mesh
  24130. */
  24131. toLeftHanded(): Mesh;
  24132. /** @hidden */
  24133. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24134. /** @hidden */
  24135. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24136. /**
  24137. * Registers for this mesh a javascript function called just before the rendering process
  24138. * @param func defines the function to call before rendering this mesh
  24139. * @returns the current mesh
  24140. */
  24141. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24142. /**
  24143. * Disposes a previously registered javascript function called before the rendering
  24144. * @param func defines the function to remove
  24145. * @returns the current mesh
  24146. */
  24147. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24148. /**
  24149. * Registers for this mesh a javascript function called just after the rendering is complete
  24150. * @param func defines the function to call after rendering this mesh
  24151. * @returns the current mesh
  24152. */
  24153. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24154. /**
  24155. * Disposes a previously registered javascript function called after the rendering.
  24156. * @param func defines the function to remove
  24157. * @returns the current mesh
  24158. */
  24159. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24160. /** @hidden */
  24161. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24162. /** @hidden */
  24163. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24164. /** @hidden */
  24165. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24166. /** @hidden */
  24167. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24168. /** @hidden */
  24169. _rebuild(): void;
  24170. /** @hidden */
  24171. _freeze(): void;
  24172. /** @hidden */
  24173. _unFreeze(): void;
  24174. /**
  24175. * 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
  24176. * @param subMesh defines the subMesh to render
  24177. * @param enableAlphaMode defines if alpha mode can be changed
  24178. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24179. * @returns the current mesh
  24180. */
  24181. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24182. private _onBeforeDraw;
  24183. /**
  24184. * Renormalize the mesh and patch it up if there are no weights
  24185. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24186. * However in the case of zero weights then we set just a single influence to 1.
  24187. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24188. */
  24189. cleanMatrixWeights(): void;
  24190. private normalizeSkinFourWeights;
  24191. private normalizeSkinWeightsAndExtra;
  24192. /**
  24193. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24194. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24195. * the user know there was an issue with importing the mesh
  24196. * @returns a validation object with skinned, valid and report string
  24197. */
  24198. validateSkinning(): {
  24199. skinned: boolean;
  24200. valid: boolean;
  24201. report: string;
  24202. };
  24203. /** @hidden */
  24204. _checkDelayState(): Mesh;
  24205. private _queueLoad;
  24206. /**
  24207. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24208. * A mesh is in the frustum if its bounding box intersects the frustum
  24209. * @param frustumPlanes defines the frustum to test
  24210. * @returns true if the mesh is in the frustum planes
  24211. */
  24212. isInFrustum(frustumPlanes: Plane[]): boolean;
  24213. /**
  24214. * Sets the mesh material by the material or multiMaterial `id` property
  24215. * @param id is a string identifying the material or the multiMaterial
  24216. * @returns the current mesh
  24217. */
  24218. setMaterialByID(id: string): Mesh;
  24219. /**
  24220. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24221. * @returns an array of IAnimatable
  24222. */
  24223. getAnimatables(): IAnimatable[];
  24224. /**
  24225. * Modifies the mesh geometry according to the passed transformation matrix.
  24226. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24227. * The mesh normals are modified using the same transformation.
  24228. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24229. * @param transform defines the transform matrix to use
  24230. * @see http://doc.babylonjs.com/resources/baking_transformations
  24231. * @returns the current mesh
  24232. */
  24233. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24234. /**
  24235. * Modifies the mesh geometry according to its own current World Matrix.
  24236. * The mesh World Matrix is then reset.
  24237. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24238. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24239. * @see http://doc.babylonjs.com/resources/baking_transformations
  24240. * @returns the current mesh
  24241. */
  24242. bakeCurrentTransformIntoVertices(): Mesh;
  24243. /** @hidden */
  24244. readonly _positions: Nullable<Vector3[]>;
  24245. /** @hidden */
  24246. _resetPointsArrayCache(): Mesh;
  24247. /** @hidden */
  24248. _generatePointsArray(): boolean;
  24249. /**
  24250. * Returns a new Mesh object generated from the current mesh properties.
  24251. * This method must not get confused with createInstance()
  24252. * @param name is a string, the name given to the new mesh
  24253. * @param newParent can be any Node object (default `null`)
  24254. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24255. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24256. * @returns a new mesh
  24257. */
  24258. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24259. /**
  24260. * Releases resources associated with this mesh.
  24261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24263. */
  24264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24265. /** @hidden */
  24266. _disposeInstanceSpecificData(): void;
  24267. /**
  24268. * Modifies the mesh geometry according to a displacement map.
  24269. * 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.
  24270. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24271. * @param url is a string, the URL from the image file is to be downloaded.
  24272. * @param minHeight is the lower limit of the displacement.
  24273. * @param maxHeight is the upper limit of the displacement.
  24274. * @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.
  24275. * @param uvOffset is an optional vector2 used to offset UV.
  24276. * @param uvScale is an optional vector2 used to scale UV.
  24277. * @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.
  24278. * @returns the Mesh.
  24279. */
  24280. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24281. /**
  24282. * Modifies the mesh geometry according to a displacementMap buffer.
  24283. * 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.
  24284. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24285. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24286. * @param heightMapWidth is the width of the buffer image.
  24287. * @param heightMapHeight is the height of the buffer image.
  24288. * @param minHeight is the lower limit of the displacement.
  24289. * @param maxHeight is the upper limit of the displacement.
  24290. * @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.
  24291. * @param uvOffset is an optional vector2 used to offset UV.
  24292. * @param uvScale is an optional vector2 used to scale UV.
  24293. * @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.
  24294. * @returns the Mesh.
  24295. */
  24296. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24297. /**
  24298. * Modify the mesh to get a flat shading rendering.
  24299. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24300. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24301. * @returns current mesh
  24302. */
  24303. convertToFlatShadedMesh(): Mesh;
  24304. /**
  24305. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24306. * In other words, more vertices, no more indices and a single bigger VBO.
  24307. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24308. * @returns current mesh
  24309. */
  24310. convertToUnIndexedMesh(): Mesh;
  24311. /**
  24312. * Inverses facet orientations.
  24313. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24314. * @param flipNormals will also inverts the normals
  24315. * @returns current mesh
  24316. */
  24317. flipFaces(flipNormals?: boolean): Mesh;
  24318. /**
  24319. * Increase the number of facets and hence vertices in a mesh
  24320. * Vertex normals are interpolated from existing vertex normals
  24321. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24322. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24323. */
  24324. increaseVertices(numberPerEdge: number): void;
  24325. /**
  24326. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24327. * This will undo any application of covertToFlatShadedMesh
  24328. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24329. */
  24330. forceSharedVertices(): void;
  24331. /** @hidden */
  24332. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24333. /** @hidden */
  24334. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24335. /**
  24336. * Creates a new InstancedMesh object from the mesh model.
  24337. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24338. * @param name defines the name of the new instance
  24339. * @returns a new InstancedMesh
  24340. */
  24341. createInstance(name: string): InstancedMesh;
  24342. /**
  24343. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24344. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24345. * @returns the current mesh
  24346. */
  24347. synchronizeInstances(): Mesh;
  24348. /**
  24349. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24350. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24351. * This should be used together with the simplification to avoid disappearing triangles.
  24352. * @param successCallback an optional success callback to be called after the optimization finished.
  24353. * @returns the current mesh
  24354. */
  24355. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24356. /**
  24357. * Serialize current mesh
  24358. * @param serializationObject defines the object which will receive the serialization data
  24359. */
  24360. serialize(serializationObject: any): void;
  24361. /** @hidden */
  24362. _syncGeometryWithMorphTargetManager(): void;
  24363. /** @hidden */
  24364. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24365. /**
  24366. * Returns a new Mesh object parsed from the source provided.
  24367. * @param parsedMesh is the source
  24368. * @param scene defines the hosting scene
  24369. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24370. * @returns a new Mesh
  24371. */
  24372. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24373. /**
  24374. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24375. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24376. * @param name defines the name of the mesh to create
  24377. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24378. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24379. * @param closePath creates a seam between the first and the last points of each path of the path array
  24380. * @param offset is taken in account only if the `pathArray` is containing a single path
  24381. * @param scene defines the hosting scene
  24382. * @param updatable defines if the mesh must be flagged as updatable
  24383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24384. * @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)
  24385. * @returns a new Mesh
  24386. */
  24387. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24388. /**
  24389. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24390. * @param name defines the name of the mesh to create
  24391. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24392. * @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
  24393. * @param scene defines the hosting scene
  24394. * @param updatable defines if the mesh must be flagged as updatable
  24395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24396. * @returns a new Mesh
  24397. */
  24398. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24399. /**
  24400. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24401. * @param name defines the name of the mesh to create
  24402. * @param size sets the size (float) of each box side (default 1)
  24403. * @param scene defines the hosting scene
  24404. * @param updatable defines if the mesh must be flagged as updatable
  24405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24406. * @returns a new Mesh
  24407. */
  24408. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24409. /**
  24410. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24411. * @param name defines the name of the mesh to create
  24412. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24413. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24414. * @param scene defines the hosting scene
  24415. * @param updatable defines if the mesh must be flagged as updatable
  24416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24417. * @returns a new Mesh
  24418. */
  24419. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24420. /**
  24421. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24422. * @param name defines the name of the mesh to create
  24423. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24424. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24425. * @param scene defines the hosting scene
  24426. * @returns a new Mesh
  24427. */
  24428. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24429. /**
  24430. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24431. * @param name defines the name of the mesh to create
  24432. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24433. * @param diameterTop set the top cap diameter (floats, default 1)
  24434. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24435. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24436. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24437. * @param scene defines the hosting scene
  24438. * @param updatable defines if the mesh must be flagged as updatable
  24439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24440. * @returns a new Mesh
  24441. */
  24442. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24443. /**
  24444. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24445. * @param name defines the name of the mesh to create
  24446. * @param diameter sets the diameter size (float) of the torus (default 1)
  24447. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24448. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24449. * @param scene defines the hosting scene
  24450. * @param updatable defines if the mesh must be flagged as updatable
  24451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24452. * @returns a new Mesh
  24453. */
  24454. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24455. /**
  24456. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24457. * @param name defines the name of the mesh to create
  24458. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24459. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24460. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24461. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24462. * @param p the number of windings on X axis (positive integers, default 2)
  24463. * @param q the number of windings on Y axis (positive integers, default 3)
  24464. * @param scene defines the hosting scene
  24465. * @param updatable defines if the mesh must be flagged as updatable
  24466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24467. * @returns a new Mesh
  24468. */
  24469. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24470. /**
  24471. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24472. * @param name defines the name of the mesh to create
  24473. * @param points is an array successive Vector3
  24474. * @param scene defines the hosting scene
  24475. * @param updatable defines if the mesh must be flagged as updatable
  24476. * @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).
  24477. * @returns a new Mesh
  24478. */
  24479. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24480. /**
  24481. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24482. * @param name defines the name of the mesh to create
  24483. * @param points is an array successive Vector3
  24484. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24485. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24486. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24487. * @param scene defines the hosting scene
  24488. * @param updatable defines if the mesh must be flagged as updatable
  24489. * @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)
  24490. * @returns a new Mesh
  24491. */
  24492. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24493. /**
  24494. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24495. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24496. * 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.
  24497. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24498. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24499. * Remember you can only change the shape positions, not their number when updating a polygon.
  24500. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24501. * @param name defines the name of the mesh to create
  24502. * @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
  24503. * @param scene defines the hosting scene
  24504. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24505. * @param updatable defines if the mesh must be flagged as updatable
  24506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24507. * @param earcutInjection can be used to inject your own earcut reference
  24508. * @returns a new Mesh
  24509. */
  24510. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24511. /**
  24512. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24513. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24514. * @param name defines the name of the mesh to create
  24515. * @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
  24516. * @param depth defines the height of extrusion
  24517. * @param scene defines the hosting scene
  24518. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24519. * @param updatable defines if the mesh must be flagged as updatable
  24520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24521. * @param earcutInjection can be used to inject your own earcut reference
  24522. * @returns a new Mesh
  24523. */
  24524. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24525. /**
  24526. * Creates an extruded shape mesh.
  24527. * 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
  24528. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24529. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24530. * @param name defines the name of the mesh to create
  24531. * @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
  24532. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24533. * @param scale is the value to scale the shape
  24534. * @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
  24535. * @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
  24536. * @param scene defines the hosting scene
  24537. * @param updatable defines if the mesh must be flagged as updatable
  24538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24539. * @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)
  24540. * @returns a new Mesh
  24541. */
  24542. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24543. /**
  24544. * Creates an custom extruded shape mesh.
  24545. * The custom extrusion is a parametric shape.
  24546. * It has no predefined shape. Its final shape will depend on the input parameters.
  24547. * Please consider using the same method from the MeshBuilder class instead
  24548. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24549. * @param name defines the name of the mesh to create
  24550. * @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
  24551. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24552. * @param scaleFunction is a custom Javascript function called on each path point
  24553. * @param rotationFunction is a custom Javascript function called on each path point
  24554. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24555. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24556. * @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
  24557. * @param scene defines the hosting scene
  24558. * @param updatable defines if the mesh must be flagged as updatable
  24559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24560. * @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)
  24561. * @returns a new Mesh
  24562. */
  24563. 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;
  24564. /**
  24565. * Creates lathe mesh.
  24566. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24567. * Please consider using the same method from the MeshBuilder class instead
  24568. * @param name defines the name of the mesh to create
  24569. * @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
  24570. * @param radius is the radius value of the lathe
  24571. * @param tessellation is the side number of the lathe.
  24572. * @param scene defines the hosting scene
  24573. * @param updatable defines if the mesh must be flagged as updatable
  24574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24575. * @returns a new Mesh
  24576. */
  24577. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24578. /**
  24579. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24580. * @param name defines the name of the mesh to create
  24581. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24582. * @param scene defines the hosting scene
  24583. * @param updatable defines if the mesh must be flagged as updatable
  24584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24585. * @returns a new Mesh
  24586. */
  24587. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24588. /**
  24589. * Creates a ground mesh.
  24590. * Please consider using the same method from the MeshBuilder class instead
  24591. * @param name defines the name of the mesh to create
  24592. * @param width set the width of the ground
  24593. * @param height set the height of the ground
  24594. * @param subdivisions sets the number of subdivisions per side
  24595. * @param scene defines the hosting scene
  24596. * @param updatable defines if the mesh must be flagged as updatable
  24597. * @returns a new Mesh
  24598. */
  24599. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24600. /**
  24601. * Creates a tiled ground mesh.
  24602. * Please consider using the same method from the MeshBuilder class instead
  24603. * @param name defines the name of the mesh to create
  24604. * @param xmin set the ground minimum X coordinate
  24605. * @param zmin set the ground minimum Y coordinate
  24606. * @param xmax set the ground maximum X coordinate
  24607. * @param zmax set the ground maximum Z coordinate
  24608. * @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
  24609. * @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
  24610. * @param scene defines the hosting scene
  24611. * @param updatable defines if the mesh must be flagged as updatable
  24612. * @returns a new Mesh
  24613. */
  24614. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24615. w: number;
  24616. h: number;
  24617. }, precision: {
  24618. w: number;
  24619. h: number;
  24620. }, scene: Scene, updatable?: boolean): Mesh;
  24621. /**
  24622. * Creates a ground mesh from a height map.
  24623. * Please consider using the same method from the MeshBuilder class instead
  24624. * @see http://doc.babylonjs.com/babylon101/height_map
  24625. * @param name defines the name of the mesh to create
  24626. * @param url sets the URL of the height map image resource
  24627. * @param width set the ground width size
  24628. * @param height set the ground height size
  24629. * @param subdivisions sets the number of subdivision per side
  24630. * @param minHeight is the minimum altitude on the ground
  24631. * @param maxHeight is the maximum altitude on the ground
  24632. * @param scene defines the hosting scene
  24633. * @param updatable defines if the mesh must be flagged as updatable
  24634. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24635. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24636. * @returns a new Mesh
  24637. */
  24638. 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;
  24639. /**
  24640. * Creates a tube mesh.
  24641. * The tube is a parametric shape.
  24642. * It has no predefined shape. Its final shape will depend on the input parameters.
  24643. * Please consider using the same method from the MeshBuilder class instead
  24644. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24645. * @param name defines the name of the mesh to create
  24646. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24647. * @param radius sets the tube radius size
  24648. * @param tessellation is the number of sides on the tubular surface
  24649. * @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
  24650. * @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
  24651. * @param scene defines the hosting scene
  24652. * @param updatable defines if the mesh must be flagged as updatable
  24653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24654. * @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)
  24655. * @returns a new Mesh
  24656. */
  24657. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24658. (i: number, distance: number): number;
  24659. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24660. /**
  24661. * Creates a polyhedron mesh.
  24662. * Please consider using the same method from the MeshBuilder class instead.
  24663. * * 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
  24664. * * The parameter `size` (positive float, default 1) sets the polygon size
  24665. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24666. * * 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`
  24667. * * 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
  24668. * * 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)`)
  24669. * * 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
  24670. * * 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
  24671. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24672. * * 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
  24673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24674. * @param name defines the name of the mesh to create
  24675. * @param options defines the options used to create the mesh
  24676. * @param scene defines the hosting scene
  24677. * @returns a new Mesh
  24678. */
  24679. static CreatePolyhedron(name: string, options: {
  24680. type?: number;
  24681. size?: number;
  24682. sizeX?: number;
  24683. sizeY?: number;
  24684. sizeZ?: number;
  24685. custom?: any;
  24686. faceUV?: Vector4[];
  24687. faceColors?: Color4[];
  24688. updatable?: boolean;
  24689. sideOrientation?: number;
  24690. }, scene: Scene): Mesh;
  24691. /**
  24692. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24693. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24694. * * 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`)
  24695. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24696. * * 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
  24697. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24698. * * 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
  24699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24700. * @param name defines the name of the mesh
  24701. * @param options defines the options used to create the mesh
  24702. * @param scene defines the hosting scene
  24703. * @returns a new Mesh
  24704. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24705. */
  24706. static CreateIcoSphere(name: string, options: {
  24707. radius?: number;
  24708. flat?: boolean;
  24709. subdivisions?: number;
  24710. sideOrientation?: number;
  24711. updatable?: boolean;
  24712. }, scene: Scene): Mesh;
  24713. /**
  24714. * Creates a decal mesh.
  24715. * Please consider using the same method from the MeshBuilder class instead.
  24716. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24717. * @param name defines the name of the mesh
  24718. * @param sourceMesh defines the mesh receiving the decal
  24719. * @param position sets the position of the decal in world coordinates
  24720. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24721. * @param size sets the decal scaling
  24722. * @param angle sets the angle to rotate the decal
  24723. * @returns a new Mesh
  24724. */
  24725. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24726. /**
  24727. * Prepare internal position array for software CPU skinning
  24728. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24729. */
  24730. setPositionsForCPUSkinning(): Float32Array;
  24731. /**
  24732. * Prepare internal normal array for software CPU skinning
  24733. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24734. */
  24735. setNormalsForCPUSkinning(): Float32Array;
  24736. /**
  24737. * Updates the vertex buffer by applying transformation from the bones
  24738. * @param skeleton defines the skeleton to apply to current mesh
  24739. * @returns the current mesh
  24740. */
  24741. applySkeleton(skeleton: Skeleton): Mesh;
  24742. /**
  24743. * 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
  24744. * @param meshes defines the list of meshes to scan
  24745. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24746. */
  24747. static MinMax(meshes: AbstractMesh[]): {
  24748. min: Vector3;
  24749. max: Vector3;
  24750. };
  24751. /**
  24752. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24753. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24754. * @returns a vector3
  24755. */
  24756. static Center(meshesOrMinMaxVector: {
  24757. min: Vector3;
  24758. max: Vector3;
  24759. } | AbstractMesh[]): Vector3;
  24760. /**
  24761. * Merge the array of meshes into a single mesh for performance reasons.
  24762. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24763. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24764. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24765. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24766. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24767. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24768. * @returns a new mesh
  24769. */
  24770. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24771. /** @hidden */
  24772. addInstance(instance: InstancedMesh): void;
  24773. /** @hidden */
  24774. removeInstance(instance: InstancedMesh): void;
  24775. }
  24776. }
  24777. declare module BABYLON {
  24778. /**
  24779. * This is the base class of all the camera used in the application.
  24780. * @see http://doc.babylonjs.com/features/cameras
  24781. */
  24782. export class Camera extends Node {
  24783. /** @hidden */
  24784. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24785. /**
  24786. * This is the default projection mode used by the cameras.
  24787. * It helps recreating a feeling of perspective and better appreciate depth.
  24788. * This is the best way to simulate real life cameras.
  24789. */
  24790. static readonly PERSPECTIVE_CAMERA: number;
  24791. /**
  24792. * This helps creating camera with an orthographic mode.
  24793. * 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.
  24794. */
  24795. static readonly ORTHOGRAPHIC_CAMERA: number;
  24796. /**
  24797. * This is the default FOV mode for perspective cameras.
  24798. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24799. */
  24800. static readonly FOVMODE_VERTICAL_FIXED: number;
  24801. /**
  24802. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24803. */
  24804. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24805. /**
  24806. * This specifies ther is no need for a camera rig.
  24807. * Basically only one eye is rendered corresponding to the camera.
  24808. */
  24809. static readonly RIG_MODE_NONE: number;
  24810. /**
  24811. * Simulates a camera Rig with one blue eye and one red eye.
  24812. * This can be use with 3d blue and red glasses.
  24813. */
  24814. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24815. /**
  24816. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24817. */
  24818. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24819. /**
  24820. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24821. */
  24822. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24823. /**
  24824. * Defines that both eyes of the camera will be rendered over under each other.
  24825. */
  24826. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24827. /**
  24828. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24829. */
  24830. static readonly RIG_MODE_VR: number;
  24831. /**
  24832. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24833. */
  24834. static readonly RIG_MODE_WEBVR: number;
  24835. /**
  24836. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24837. */
  24838. static readonly RIG_MODE_CUSTOM: number;
  24839. /**
  24840. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24841. */
  24842. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24843. /**
  24844. * Define the input manager associated with the camera.
  24845. */
  24846. inputs: CameraInputsManager<Camera>;
  24847. /** @hidden */
  24848. _position: Vector3;
  24849. /**
  24850. * Define the current local position of the camera in the scene
  24851. */
  24852. position: Vector3;
  24853. /**
  24854. * The vector the camera should consider as up.
  24855. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24856. */
  24857. upVector: Vector3;
  24858. /**
  24859. * Define the current limit on the left side for an orthographic camera
  24860. * In scene unit
  24861. */
  24862. orthoLeft: Nullable<number>;
  24863. /**
  24864. * Define the current limit on the right side for an orthographic camera
  24865. * In scene unit
  24866. */
  24867. orthoRight: Nullable<number>;
  24868. /**
  24869. * Define the current limit on the bottom side for an orthographic camera
  24870. * In scene unit
  24871. */
  24872. orthoBottom: Nullable<number>;
  24873. /**
  24874. * Define the current limit on the top side for an orthographic camera
  24875. * In scene unit
  24876. */
  24877. orthoTop: Nullable<number>;
  24878. /**
  24879. * Field Of View is set in Radians. (default is 0.8)
  24880. */
  24881. fov: number;
  24882. /**
  24883. * Define the minimum distance the camera can see from.
  24884. * This is important to note that the depth buffer are not infinite and the closer it starts
  24885. * the more your scene might encounter depth fighting issue.
  24886. */
  24887. minZ: number;
  24888. /**
  24889. * Define the maximum distance the camera can see to.
  24890. * This is important to note that the depth buffer are not infinite and the further it end
  24891. * the more your scene might encounter depth fighting issue.
  24892. */
  24893. maxZ: number;
  24894. /**
  24895. * Define the default inertia of the camera.
  24896. * This helps giving a smooth feeling to the camera movement.
  24897. */
  24898. inertia: number;
  24899. /**
  24900. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24901. */
  24902. mode: number;
  24903. /**
  24904. * Define wether the camera is intermediate.
  24905. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24906. */
  24907. isIntermediate: boolean;
  24908. /**
  24909. * Define the viewport of the camera.
  24910. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24911. */
  24912. viewport: Viewport;
  24913. /**
  24914. * Restricts the camera to viewing objects with the same layerMask.
  24915. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24916. */
  24917. layerMask: number;
  24918. /**
  24919. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24920. */
  24921. fovMode: number;
  24922. /**
  24923. * Rig mode of the camera.
  24924. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24925. * This is normally controlled byt the camera themselves as internal use.
  24926. */
  24927. cameraRigMode: number;
  24928. /**
  24929. * Defines the distance between both "eyes" in case of a RIG
  24930. */
  24931. interaxialDistance: number;
  24932. /**
  24933. * Defines if stereoscopic rendering is done side by side or over under.
  24934. */
  24935. isStereoscopicSideBySide: boolean;
  24936. /**
  24937. * 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
  24938. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24939. * else in the scene. (Eg. security camera)
  24940. *
  24941. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24942. */
  24943. customRenderTargets: RenderTargetTexture[];
  24944. /**
  24945. * When set, the camera will render to this render target instead of the default canvas
  24946. *
  24947. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24948. */
  24949. outputRenderTarget: Nullable<RenderTargetTexture>;
  24950. /**
  24951. * Observable triggered when the camera view matrix has changed.
  24952. */
  24953. onViewMatrixChangedObservable: Observable<Camera>;
  24954. /**
  24955. * Observable triggered when the camera Projection matrix has changed.
  24956. */
  24957. onProjectionMatrixChangedObservable: Observable<Camera>;
  24958. /**
  24959. * Observable triggered when the inputs have been processed.
  24960. */
  24961. onAfterCheckInputsObservable: Observable<Camera>;
  24962. /**
  24963. * Observable triggered when reset has been called and applied to the camera.
  24964. */
  24965. onRestoreStateObservable: Observable<Camera>;
  24966. /** @hidden */
  24967. _cameraRigParams: any;
  24968. /** @hidden */
  24969. _rigCameras: Camera[];
  24970. /** @hidden */
  24971. _rigPostProcess: Nullable<PostProcess>;
  24972. protected _webvrViewMatrix: Matrix;
  24973. /** @hidden */
  24974. _skipRendering: boolean;
  24975. /** @hidden */
  24976. _projectionMatrix: Matrix;
  24977. /** @hidden */
  24978. _postProcesses: Nullable<PostProcess>[];
  24979. /** @hidden */
  24980. _activeMeshes: SmartArray<AbstractMesh>;
  24981. protected _globalPosition: Vector3;
  24982. /** @hidden */
  24983. _computedViewMatrix: Matrix;
  24984. private _doNotComputeProjectionMatrix;
  24985. private _transformMatrix;
  24986. private _frustumPlanes;
  24987. private _refreshFrustumPlanes;
  24988. private _storedFov;
  24989. private _stateStored;
  24990. /**
  24991. * Instantiates a new camera object.
  24992. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24993. * @see http://doc.babylonjs.com/features/cameras
  24994. * @param name Defines the name of the camera in the scene
  24995. * @param position Defines the position of the camera
  24996. * @param scene Defines the scene the camera belongs too
  24997. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24998. */
  24999. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25000. /**
  25001. * Store current camera state (fov, position, etc..)
  25002. * @returns the camera
  25003. */
  25004. storeState(): Camera;
  25005. /**
  25006. * Restores the camera state values if it has been stored. You must call storeState() first
  25007. */
  25008. protected _restoreStateValues(): boolean;
  25009. /**
  25010. * Restored camera state. You must call storeState() first.
  25011. * @returns true if restored and false otherwise
  25012. */
  25013. restoreState(): boolean;
  25014. /**
  25015. * Gets the class name of the camera.
  25016. * @returns the class name
  25017. */
  25018. getClassName(): string;
  25019. /** @hidden */
  25020. readonly _isCamera: boolean;
  25021. /**
  25022. * Gets a string representation of the camera useful for debug purpose.
  25023. * @param fullDetails Defines that a more verboe level of logging is required
  25024. * @returns the string representation
  25025. */
  25026. toString(fullDetails?: boolean): string;
  25027. /**
  25028. * Gets the current world space position of the camera.
  25029. */
  25030. readonly globalPosition: Vector3;
  25031. /**
  25032. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25033. * @returns the active meshe list
  25034. */
  25035. getActiveMeshes(): SmartArray<AbstractMesh>;
  25036. /**
  25037. * Check wether a mesh is part of the current active mesh list of the camera
  25038. * @param mesh Defines the mesh to check
  25039. * @returns true if active, false otherwise
  25040. */
  25041. isActiveMesh(mesh: Mesh): boolean;
  25042. /**
  25043. * Is this camera ready to be used/rendered
  25044. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25045. * @return true if the camera is ready
  25046. */
  25047. isReady(completeCheck?: boolean): boolean;
  25048. /** @hidden */
  25049. _initCache(): void;
  25050. /** @hidden */
  25051. _updateCache(ignoreParentClass?: boolean): void;
  25052. /** @hidden */
  25053. _isSynchronized(): boolean;
  25054. /** @hidden */
  25055. _isSynchronizedViewMatrix(): boolean;
  25056. /** @hidden */
  25057. _isSynchronizedProjectionMatrix(): boolean;
  25058. /**
  25059. * Attach the input controls to a specific dom element to get the input from.
  25060. * @param element Defines the element the controls should be listened from
  25061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25062. */
  25063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25064. /**
  25065. * Detach the current controls from the specified dom element.
  25066. * @param element Defines the element to stop listening the inputs from
  25067. */
  25068. detachControl(element: HTMLElement): void;
  25069. /**
  25070. * Update the camera state according to the different inputs gathered during the frame.
  25071. */
  25072. update(): void;
  25073. /** @hidden */
  25074. _checkInputs(): void;
  25075. /** @hidden */
  25076. readonly rigCameras: Camera[];
  25077. /**
  25078. * Gets the post process used by the rig cameras
  25079. */
  25080. readonly rigPostProcess: Nullable<PostProcess>;
  25081. /**
  25082. * Internal, gets the first post proces.
  25083. * @returns the first post process to be run on this camera.
  25084. */
  25085. _getFirstPostProcess(): Nullable<PostProcess>;
  25086. private _cascadePostProcessesToRigCams;
  25087. /**
  25088. * Attach a post process to the camera.
  25089. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25090. * @param postProcess The post process to attach to the camera
  25091. * @param insertAt The position of the post process in case several of them are in use in the scene
  25092. * @returns the position the post process has been inserted at
  25093. */
  25094. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25095. /**
  25096. * Detach a post process to the camera.
  25097. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25098. * @param postProcess The post process to detach from the camera
  25099. */
  25100. detachPostProcess(postProcess: PostProcess): void;
  25101. /**
  25102. * Gets the current world matrix of the camera
  25103. */
  25104. getWorldMatrix(): Matrix;
  25105. /** @hidden */
  25106. _getViewMatrix(): Matrix;
  25107. /**
  25108. * Gets the current view matrix of the camera.
  25109. * @param force forces the camera to recompute the matrix without looking at the cached state
  25110. * @returns the view matrix
  25111. */
  25112. getViewMatrix(force?: boolean): Matrix;
  25113. /**
  25114. * Freeze the projection matrix.
  25115. * It will prevent the cache check of the camera projection compute and can speed up perf
  25116. * if no parameter of the camera are meant to change
  25117. * @param projection Defines manually a projection if necessary
  25118. */
  25119. freezeProjectionMatrix(projection?: Matrix): void;
  25120. /**
  25121. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25122. */
  25123. unfreezeProjectionMatrix(): void;
  25124. /**
  25125. * Gets the current projection matrix of the camera.
  25126. * @param force forces the camera to recompute the matrix without looking at the cached state
  25127. * @returns the projection matrix
  25128. */
  25129. getProjectionMatrix(force?: boolean): Matrix;
  25130. /**
  25131. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25132. * @returns a Matrix
  25133. */
  25134. getTransformationMatrix(): Matrix;
  25135. private _updateFrustumPlanes;
  25136. /**
  25137. * Checks if a cullable object (mesh...) is in the camera frustum
  25138. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25139. * @param target The object to check
  25140. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25141. * @returns true if the object is in frustum otherwise false
  25142. */
  25143. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25144. /**
  25145. * Checks if a cullable object (mesh...) is in the camera frustum
  25146. * Unlike isInFrustum this cheks the full bounding box
  25147. * @param target The object to check
  25148. * @returns true if the object is in frustum otherwise false
  25149. */
  25150. isCompletelyInFrustum(target: ICullable): boolean;
  25151. /**
  25152. * Gets a ray in the forward direction from the camera.
  25153. * @param length Defines the length of the ray to create
  25154. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25155. * @param origin Defines the start point of the ray which defaults to the camera position
  25156. * @returns the forward ray
  25157. */
  25158. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25159. /**
  25160. * Releases resources associated with this node.
  25161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25163. */
  25164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25165. /** @hidden */
  25166. _isLeftCamera: boolean;
  25167. /**
  25168. * Gets the left camera of a rig setup in case of Rigged Camera
  25169. */
  25170. readonly isLeftCamera: boolean;
  25171. /** @hidden */
  25172. _isRightCamera: boolean;
  25173. /**
  25174. * Gets the right camera of a rig setup in case of Rigged Camera
  25175. */
  25176. readonly isRightCamera: boolean;
  25177. /**
  25178. * Gets the left camera of a rig setup in case of Rigged Camera
  25179. */
  25180. readonly leftCamera: Nullable<FreeCamera>;
  25181. /**
  25182. * Gets the right camera of a rig setup in case of Rigged Camera
  25183. */
  25184. readonly rightCamera: Nullable<FreeCamera>;
  25185. /**
  25186. * Gets the left camera target of a rig setup in case of Rigged Camera
  25187. * @returns the target position
  25188. */
  25189. getLeftTarget(): Nullable<Vector3>;
  25190. /**
  25191. * Gets the right camera target of a rig setup in case of Rigged Camera
  25192. * @returns the target position
  25193. */
  25194. getRightTarget(): Nullable<Vector3>;
  25195. /**
  25196. * @hidden
  25197. */
  25198. setCameraRigMode(mode: number, rigParams: any): void;
  25199. /** @hidden */
  25200. static _setStereoscopicRigMode(camera: Camera): void;
  25201. /** @hidden */
  25202. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25203. /** @hidden */
  25204. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25205. /** @hidden */
  25206. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25207. /** @hidden */
  25208. _getVRProjectionMatrix(): Matrix;
  25209. protected _updateCameraRotationMatrix(): void;
  25210. protected _updateWebVRCameraRotationMatrix(): void;
  25211. /**
  25212. * This function MUST be overwritten by the different WebVR cameras available.
  25213. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25214. * @hidden
  25215. */
  25216. _getWebVRProjectionMatrix(): Matrix;
  25217. /**
  25218. * This function MUST be overwritten by the different WebVR cameras available.
  25219. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25220. * @hidden
  25221. */
  25222. _getWebVRViewMatrix(): Matrix;
  25223. /** @hidden */
  25224. setCameraRigParameter(name: string, value: any): void;
  25225. /**
  25226. * needs to be overridden by children so sub has required properties to be copied
  25227. * @hidden
  25228. */
  25229. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25230. /**
  25231. * May need to be overridden by children
  25232. * @hidden
  25233. */
  25234. _updateRigCameras(): void;
  25235. /** @hidden */
  25236. _setupInputs(): void;
  25237. /**
  25238. * Serialiaze the camera setup to a json represention
  25239. * @returns the JSON representation
  25240. */
  25241. serialize(): any;
  25242. /**
  25243. * Clones the current camera.
  25244. * @param name The cloned camera name
  25245. * @returns the cloned camera
  25246. */
  25247. clone(name: string): Camera;
  25248. /**
  25249. * Gets the direction of the camera relative to a given local axis.
  25250. * @param localAxis Defines the reference axis to provide a relative direction.
  25251. * @return the direction
  25252. */
  25253. getDirection(localAxis: Vector3): Vector3;
  25254. /**
  25255. * Returns the current camera absolute rotation
  25256. */
  25257. readonly absoluteRotation: Quaternion;
  25258. /**
  25259. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25260. * @param localAxis Defines the reference axis to provide a relative direction.
  25261. * @param result Defines the vector to store the result in
  25262. */
  25263. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25264. /**
  25265. * Gets a camera constructor for a given camera type
  25266. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25267. * @param name The name of the camera the result will be able to instantiate
  25268. * @param scene The scene the result will construct the camera in
  25269. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25270. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25271. * @returns a factory method to construc the camera
  25272. */
  25273. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25274. /**
  25275. * Compute the world matrix of the camera.
  25276. * @returns the camera world matrix
  25277. */
  25278. computeWorldMatrix(): Matrix;
  25279. /**
  25280. * Parse a JSON and creates the camera from the parsed information
  25281. * @param parsedCamera The JSON to parse
  25282. * @param scene The scene to instantiate the camera in
  25283. * @returns the newly constructed camera
  25284. */
  25285. static Parse(parsedCamera: any, scene: Scene): Camera;
  25286. }
  25287. }
  25288. declare module BABYLON {
  25289. /**
  25290. * Class containing static functions to help procedurally build meshes
  25291. */
  25292. export class DiscBuilder {
  25293. /**
  25294. * Creates a plane polygonal mesh. By default, this is a disc
  25295. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25296. * * 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
  25297. * * 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
  25298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25299. * * 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
  25300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25301. * @param name defines the name of the mesh
  25302. * @param options defines the options used to create the mesh
  25303. * @param scene defines the hosting scene
  25304. * @returns the plane polygonal mesh
  25305. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25306. */
  25307. static CreateDisc(name: string, options: {
  25308. radius?: number;
  25309. tessellation?: number;
  25310. arc?: number;
  25311. updatable?: boolean;
  25312. sideOrientation?: number;
  25313. frontUVs?: Vector4;
  25314. backUVs?: Vector4;
  25315. }, scene?: Nullable<Scene>): Mesh;
  25316. }
  25317. }
  25318. declare module BABYLON {
  25319. /**
  25320. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25321. *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.
  25322. * The SPS is also a particle system. It provides some methods to manage the particles.
  25323. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25324. *
  25325. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25326. */
  25327. export class SolidParticleSystem implements IDisposable {
  25328. /**
  25329. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25330. * Example : var p = SPS.particles[i];
  25331. */
  25332. particles: SolidParticle[];
  25333. /**
  25334. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25335. */
  25336. nbParticles: number;
  25337. /**
  25338. * If the particles must ever face the camera (default false). Useful for planar particles.
  25339. */
  25340. billboard: boolean;
  25341. /**
  25342. * Recompute normals when adding a shape
  25343. */
  25344. recomputeNormals: boolean;
  25345. /**
  25346. * This a counter ofr your own usage. It's not set by any SPS functions.
  25347. */
  25348. counter: number;
  25349. /**
  25350. * The SPS name. This name is also given to the underlying mesh.
  25351. */
  25352. name: string;
  25353. /**
  25354. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25355. */
  25356. mesh: Mesh;
  25357. /**
  25358. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25359. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25360. */
  25361. vars: any;
  25362. /**
  25363. * This array is populated when the SPS is set as 'pickable'.
  25364. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25365. * Each element of this array is an object `{idx: int, faceId: int}`.
  25366. * `idx` is the picked particle index in the `SPS.particles` array
  25367. * `faceId` is the picked face index counted within this particle.
  25368. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25369. */
  25370. pickedParticles: {
  25371. idx: number;
  25372. faceId: number;
  25373. }[];
  25374. /**
  25375. * This array is populated when `enableDepthSort` is set to true.
  25376. * Each element of this array is an instance of the class DepthSortedParticle.
  25377. */
  25378. depthSortedParticles: DepthSortedParticle[];
  25379. /**
  25380. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25381. * @hidden
  25382. */
  25383. _bSphereOnly: boolean;
  25384. /**
  25385. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25386. * @hidden
  25387. */
  25388. _bSphereRadiusFactor: number;
  25389. private _scene;
  25390. private _positions;
  25391. private _indices;
  25392. private _normals;
  25393. private _colors;
  25394. private _uvs;
  25395. private _indices32;
  25396. private _positions32;
  25397. private _normals32;
  25398. private _fixedNormal32;
  25399. private _colors32;
  25400. private _uvs32;
  25401. private _index;
  25402. private _updatable;
  25403. private _pickable;
  25404. private _isVisibilityBoxLocked;
  25405. private _alwaysVisible;
  25406. private _depthSort;
  25407. private _expandable;
  25408. private _shapeCounter;
  25409. private _copy;
  25410. private _color;
  25411. private _computeParticleColor;
  25412. private _computeParticleTexture;
  25413. private _computeParticleRotation;
  25414. private _computeParticleVertex;
  25415. private _computeBoundingBox;
  25416. private _depthSortParticles;
  25417. private _camera;
  25418. private _mustUnrotateFixedNormals;
  25419. private _particlesIntersect;
  25420. private _needs32Bits;
  25421. private _isNotBuilt;
  25422. /**
  25423. * Creates a SPS (Solid Particle System) object.
  25424. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25425. * @param scene (Scene) is the scene in which the SPS is added.
  25426. * @param options defines the options of the sps e.g.
  25427. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25428. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25429. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25430. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25431. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25432. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25433. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25434. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25435. */
  25436. constructor(name: string, scene: Scene, options?: {
  25437. updatable?: boolean;
  25438. isPickable?: boolean;
  25439. enableDepthSort?: boolean;
  25440. particleIntersection?: boolean;
  25441. boundingSphereOnly?: boolean;
  25442. bSphereRadiusFactor?: number;
  25443. expandable?: boolean;
  25444. });
  25445. /**
  25446. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25447. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25448. * @returns the created mesh
  25449. */
  25450. buildMesh(): Mesh;
  25451. /**
  25452. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25453. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25454. * Thus the particles generated from `digest()` have their property `position` set yet.
  25455. * @param mesh ( Mesh ) is the mesh to be digested
  25456. * @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
  25457. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25458. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25459. * @returns the current SPS
  25460. */
  25461. digest(mesh: Mesh, options?: {
  25462. facetNb?: number;
  25463. number?: number;
  25464. delta?: number;
  25465. }): SolidParticleSystem;
  25466. private _unrotateFixedNormals;
  25467. private _resetCopy;
  25468. private _meshBuilder;
  25469. private _posToShape;
  25470. private _uvsToShapeUV;
  25471. private _addParticle;
  25472. /**
  25473. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25474. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25475. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25476. * @param nb (positive integer) the number of particles to be created from this model
  25477. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25478. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25479. * @returns the number of shapes in the system
  25480. */
  25481. addShape(mesh: Mesh, nb: number, options?: {
  25482. positionFunction?: any;
  25483. vertexFunction?: any;
  25484. }): number;
  25485. private _rebuildParticle;
  25486. /**
  25487. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25488. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25489. * @returns the SPS.
  25490. */
  25491. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25492. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25493. * Returns an array with the removed particles.
  25494. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25495. * The SPS can't be empty so at least one particle needs to remain in place.
  25496. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25497. * @param start index of the first particle to remove
  25498. * @param end index of the last particle to remove (included)
  25499. * @returns an array populated with the removed particles
  25500. */
  25501. removeParticles(start: number, end: number): SolidParticle[];
  25502. /**
  25503. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25504. * This method calls `updateParticle()` for each particle of the SPS.
  25505. * For an animated SPS, it is usually called within the render loop.
  25506. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25507. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25508. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25509. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25510. * @returns the SPS.
  25511. */
  25512. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25513. /**
  25514. * Disposes the SPS.
  25515. */
  25516. dispose(): void;
  25517. /**
  25518. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25519. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25520. * @returns the SPS.
  25521. */
  25522. refreshVisibleSize(): SolidParticleSystem;
  25523. /**
  25524. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25525. * @param size the size (float) of the visibility box
  25526. * note : this doesn't lock the SPS mesh bounding box.
  25527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25528. */
  25529. setVisibilityBox(size: number): void;
  25530. /**
  25531. * Gets whether the SPS as always visible or not
  25532. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25533. */
  25534. /**
  25535. * Sets the SPS as always visible or not
  25536. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25537. */
  25538. isAlwaysVisible: boolean;
  25539. /**
  25540. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25541. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25542. */
  25543. /**
  25544. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25545. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25546. */
  25547. isVisibilityBoxLocked: boolean;
  25548. /**
  25549. * Tells to `setParticles()` to compute the particle rotations or not.
  25550. * Default value : true. The SPS is faster when it's set to false.
  25551. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25552. */
  25553. /**
  25554. * Gets if `setParticles()` computes the particle rotations or not.
  25555. * Default value : true. The SPS is faster when it's set to false.
  25556. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25557. */
  25558. computeParticleRotation: boolean;
  25559. /**
  25560. * Tells to `setParticles()` to compute the particle colors or not.
  25561. * Default value : true. The SPS is faster when it's set to false.
  25562. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25563. */
  25564. /**
  25565. * Gets if `setParticles()` computes the particle colors or not.
  25566. * Default value : true. The SPS is faster when it's set to false.
  25567. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25568. */
  25569. computeParticleColor: boolean;
  25570. /**
  25571. * Gets if `setParticles()` computes the particle textures or not.
  25572. * Default value : true. The SPS is faster when it's set to false.
  25573. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25574. */
  25575. computeParticleTexture: boolean;
  25576. /**
  25577. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25578. * Default value : false. The SPS is faster when it's set to false.
  25579. * Note : the particle custom vertex positions aren't stored values.
  25580. */
  25581. /**
  25582. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25583. * Default value : false. The SPS is faster when it's set to false.
  25584. * Note : the particle custom vertex positions aren't stored values.
  25585. */
  25586. computeParticleVertex: boolean;
  25587. /**
  25588. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25589. */
  25590. /**
  25591. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25592. */
  25593. computeBoundingBox: boolean;
  25594. /**
  25595. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25596. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25597. * Default : `true`
  25598. */
  25599. /**
  25600. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25601. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25602. * Default : `true`
  25603. */
  25604. depthSortParticles: boolean;
  25605. /**
  25606. * Gets if the SPS is created as expandable at construction time.
  25607. * Default : `false`
  25608. */
  25609. readonly expandable: boolean;
  25610. /**
  25611. * This function does nothing. It may be overwritten to set all the particle first values.
  25612. * The SPS doesn't call this function, you may have to call it by your own.
  25613. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25614. */
  25615. initParticles(): void;
  25616. /**
  25617. * This function does nothing. It may be overwritten to recycle a particle.
  25618. * The SPS doesn't call this function, you may have to call it by your own.
  25619. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25620. * @param particle The particle to recycle
  25621. * @returns the recycled particle
  25622. */
  25623. recycleParticle(particle: SolidParticle): SolidParticle;
  25624. /**
  25625. * Updates a particle : this function should be overwritten by the user.
  25626. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25628. * @example : just set a particle position or velocity and recycle conditions
  25629. * @param particle The particle to update
  25630. * @returns the updated particle
  25631. */
  25632. updateParticle(particle: SolidParticle): SolidParticle;
  25633. /**
  25634. * Updates a vertex of a particle : it can be overwritten by the user.
  25635. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25636. * @param particle the current particle
  25637. * @param vertex the current index of the current particle
  25638. * @param pt the index of the current vertex in the particle shape
  25639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25640. * @example : just set a vertex particle position
  25641. * @returns the updated vertex
  25642. */
  25643. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25644. /**
  25645. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25646. * This does nothing and may be overwritten by the user.
  25647. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25648. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25649. * @param update the boolean update value actually passed to setParticles()
  25650. */
  25651. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25652. /**
  25653. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25654. * This will be passed three parameters.
  25655. * This does nothing and may be overwritten by the user.
  25656. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25657. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25658. * @param update the boolean update value actually passed to setParticles()
  25659. */
  25660. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25661. }
  25662. }
  25663. declare module BABYLON {
  25664. /**
  25665. * Represents one particle of a solid particle system.
  25666. */
  25667. export class SolidParticle {
  25668. /**
  25669. * particle global index
  25670. */
  25671. idx: number;
  25672. /**
  25673. * The color of the particle
  25674. */
  25675. color: Nullable<Color4>;
  25676. /**
  25677. * The world space position of the particle.
  25678. */
  25679. position: Vector3;
  25680. /**
  25681. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25682. */
  25683. rotation: Vector3;
  25684. /**
  25685. * The world space rotation quaternion of the particle.
  25686. */
  25687. rotationQuaternion: Nullable<Quaternion>;
  25688. /**
  25689. * The scaling of the particle.
  25690. */
  25691. scaling: Vector3;
  25692. /**
  25693. * The uvs of the particle.
  25694. */
  25695. uvs: Vector4;
  25696. /**
  25697. * The current speed of the particle.
  25698. */
  25699. velocity: Vector3;
  25700. /**
  25701. * The pivot point in the particle local space.
  25702. */
  25703. pivot: Vector3;
  25704. /**
  25705. * Must the particle be translated from its pivot point in its local space ?
  25706. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25707. * Default : false
  25708. */
  25709. translateFromPivot: boolean;
  25710. /**
  25711. * Is the particle active or not ?
  25712. */
  25713. alive: boolean;
  25714. /**
  25715. * Is the particle visible or not ?
  25716. */
  25717. isVisible: boolean;
  25718. /**
  25719. * Index of this particle in the global "positions" array (Internal use)
  25720. * @hidden
  25721. */
  25722. _pos: number;
  25723. /**
  25724. * @hidden Index of this particle in the global "indices" array (Internal use)
  25725. */
  25726. _ind: number;
  25727. /**
  25728. * @hidden ModelShape of this particle (Internal use)
  25729. */
  25730. _model: ModelShape;
  25731. /**
  25732. * ModelShape id of this particle
  25733. */
  25734. shapeId: number;
  25735. /**
  25736. * Index of the particle in its shape id
  25737. */
  25738. idxInShape: number;
  25739. /**
  25740. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25741. */
  25742. _modelBoundingInfo: BoundingInfo;
  25743. /**
  25744. * @hidden Particle BoundingInfo object (Internal use)
  25745. */
  25746. _boundingInfo: BoundingInfo;
  25747. /**
  25748. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25749. */
  25750. _sps: SolidParticleSystem;
  25751. /**
  25752. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25753. */
  25754. _stillInvisible: boolean;
  25755. /**
  25756. * @hidden Last computed particle rotation matrix
  25757. */
  25758. _rotationMatrix: number[];
  25759. /**
  25760. * Parent particle Id, if any.
  25761. * Default null.
  25762. */
  25763. parentId: Nullable<number>;
  25764. /**
  25765. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25766. * The possible values are :
  25767. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25768. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25769. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25770. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25771. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25772. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25773. * */
  25774. cullingStrategy: number;
  25775. /**
  25776. * @hidden Internal global position in the SPS.
  25777. */
  25778. _globalPosition: Vector3;
  25779. /**
  25780. * Creates a Solid Particle object.
  25781. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25782. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25783. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25784. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25785. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25786. * @param shapeId (integer) is the model shape identifier in the SPS.
  25787. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25788. * @param sps defines the sps it is associated to
  25789. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25790. */
  25791. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25792. /**
  25793. * Legacy support, changed scale to scaling
  25794. */
  25795. /**
  25796. * Legacy support, changed scale to scaling
  25797. */
  25798. scale: Vector3;
  25799. /**
  25800. * Legacy support, changed quaternion to rotationQuaternion
  25801. */
  25802. /**
  25803. * Legacy support, changed quaternion to rotationQuaternion
  25804. */
  25805. quaternion: Nullable<Quaternion>;
  25806. /**
  25807. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25808. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25809. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25810. * @returns true if it intersects
  25811. */
  25812. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25813. /**
  25814. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25815. * A particle is in the frustum if its bounding box intersects the frustum
  25816. * @param frustumPlanes defines the frustum to test
  25817. * @returns true if the particle is in the frustum planes
  25818. */
  25819. isInFrustum(frustumPlanes: Plane[]): boolean;
  25820. /**
  25821. * get the rotation matrix of the particle
  25822. * @hidden
  25823. */
  25824. getRotationMatrix(m: Matrix): void;
  25825. }
  25826. /**
  25827. * Represents the shape of the model used by one particle of a solid particle system.
  25828. * SPS internal tool, don't use it manually.
  25829. */
  25830. export class ModelShape {
  25831. /**
  25832. * The shape id
  25833. * @hidden
  25834. */
  25835. shapeID: number;
  25836. /**
  25837. * flat array of model positions (internal use)
  25838. * @hidden
  25839. */
  25840. _shape: Vector3[];
  25841. /**
  25842. * flat array of model UVs (internal use)
  25843. * @hidden
  25844. */
  25845. _shapeUV: number[];
  25846. /**
  25847. * color array of the model
  25848. * @hidden
  25849. */
  25850. _shapeColors: number[];
  25851. /**
  25852. * indices array of the model
  25853. * @hidden
  25854. */
  25855. _indices: number[];
  25856. /**
  25857. * normals array of the model
  25858. * @hidden
  25859. */
  25860. _normals: number[];
  25861. /**
  25862. * length of the shape in the model indices array (internal use)
  25863. * @hidden
  25864. */
  25865. _indicesLength: number;
  25866. /**
  25867. * Custom position function (internal use)
  25868. * @hidden
  25869. */
  25870. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25871. /**
  25872. * Custom vertex function (internal use)
  25873. * @hidden
  25874. */
  25875. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25876. /**
  25877. * 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.
  25878. * SPS internal tool, don't use it manually.
  25879. * @hidden
  25880. */
  25881. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25882. }
  25883. /**
  25884. * Represents a Depth Sorted Particle in the solid particle system.
  25885. */
  25886. export class DepthSortedParticle {
  25887. /**
  25888. * Index of the particle in the "indices" array
  25889. */
  25890. ind: number;
  25891. /**
  25892. * Length of the particle shape in the "indices" array
  25893. */
  25894. indicesLength: number;
  25895. /**
  25896. * Squared distance from the particle to the camera
  25897. */
  25898. sqDistance: number;
  25899. }
  25900. }
  25901. declare module BABYLON {
  25902. /**
  25903. * @hidden
  25904. */
  25905. export class _MeshCollisionData {
  25906. _checkCollisions: boolean;
  25907. _collisionMask: number;
  25908. _collisionGroup: number;
  25909. _collider: Nullable<Collider>;
  25910. _oldPositionForCollisions: Vector3;
  25911. _diffPositionForCollisions: Vector3;
  25912. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25913. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25914. }
  25915. }
  25916. declare module BABYLON {
  25917. /** @hidden */
  25918. class _FacetDataStorage {
  25919. facetPositions: Vector3[];
  25920. facetNormals: Vector3[];
  25921. facetPartitioning: number[][];
  25922. facetNb: number;
  25923. partitioningSubdivisions: number;
  25924. partitioningBBoxRatio: number;
  25925. facetDataEnabled: boolean;
  25926. facetParameters: any;
  25927. bbSize: Vector3;
  25928. subDiv: {
  25929. max: number;
  25930. X: number;
  25931. Y: number;
  25932. Z: number;
  25933. };
  25934. facetDepthSort: boolean;
  25935. facetDepthSortEnabled: boolean;
  25936. depthSortedIndices: IndicesArray;
  25937. depthSortedFacets: {
  25938. ind: number;
  25939. sqDistance: number;
  25940. }[];
  25941. facetDepthSortFunction: (f1: {
  25942. ind: number;
  25943. sqDistance: number;
  25944. }, f2: {
  25945. ind: number;
  25946. sqDistance: number;
  25947. }) => number;
  25948. facetDepthSortFrom: Vector3;
  25949. facetDepthSortOrigin: Vector3;
  25950. invertedMatrix: Matrix;
  25951. }
  25952. /**
  25953. * @hidden
  25954. **/
  25955. class _InternalAbstractMeshDataInfo {
  25956. _hasVertexAlpha: boolean;
  25957. _useVertexColors: boolean;
  25958. _numBoneInfluencers: number;
  25959. _applyFog: boolean;
  25960. _receiveShadows: boolean;
  25961. _facetData: _FacetDataStorage;
  25962. _visibility: number;
  25963. _skeleton: Nullable<Skeleton>;
  25964. _layerMask: number;
  25965. _computeBonesUsingShaders: boolean;
  25966. _isActive: boolean;
  25967. _onlyForInstances: boolean;
  25968. _isActiveIntermediate: boolean;
  25969. _onlyForInstancesIntermediate: boolean;
  25970. _actAsRegularMesh: boolean;
  25971. }
  25972. /**
  25973. * Class used to store all common mesh properties
  25974. */
  25975. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25976. /** No occlusion */
  25977. static OCCLUSION_TYPE_NONE: number;
  25978. /** Occlusion set to optimisitic */
  25979. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25980. /** Occlusion set to strict */
  25981. static OCCLUSION_TYPE_STRICT: number;
  25982. /** Use an accurante occlusion algorithm */
  25983. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25984. /** Use a conservative occlusion algorithm */
  25985. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25987. * Test order :
  25988. * Is the bounding sphere outside the frustum ?
  25989. * If not, are the bounding box vertices outside the frustum ?
  25990. * It not, then the cullable object is in the frustum.
  25991. */
  25992. static readonly CULLINGSTRATEGY_STANDARD: number;
  25993. /** Culling strategy : Bounding Sphere Only.
  25994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25995. * It's also less accurate than the standard because some not visible objects can still be selected.
  25996. * Test : is the bounding sphere outside the frustum ?
  25997. * If not, then the cullable object is in the frustum.
  25998. */
  25999. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26000. /** Culling strategy : Optimistic Inclusion.
  26001. * This in an inclusion test first, then the standard exclusion test.
  26002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26003. * 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.
  26004. * Anyway, it's as accurate as the standard strategy.
  26005. * Test :
  26006. * Is the cullable object bounding sphere center in the frustum ?
  26007. * If not, apply the default culling strategy.
  26008. */
  26009. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26013. * 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.
  26014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26015. * Test :
  26016. * Is the cullable object bounding sphere center in the frustum ?
  26017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26018. */
  26019. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26020. /**
  26021. * No billboard
  26022. */
  26023. static readonly BILLBOARDMODE_NONE: number;
  26024. /** Billboard on X axis */
  26025. static readonly BILLBOARDMODE_X: number;
  26026. /** Billboard on Y axis */
  26027. static readonly BILLBOARDMODE_Y: number;
  26028. /** Billboard on Z axis */
  26029. static readonly BILLBOARDMODE_Z: number;
  26030. /** Billboard on all axes */
  26031. static readonly BILLBOARDMODE_ALL: number;
  26032. /** Billboard on using position instead of orientation */
  26033. static readonly BILLBOARDMODE_USE_POSITION: number;
  26034. /** @hidden */
  26035. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26036. /**
  26037. * The culling strategy to use to check whether the mesh must be rendered or not.
  26038. * This value can be changed at any time and will be used on the next render mesh selection.
  26039. * The possible values are :
  26040. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26041. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26042. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26043. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26044. * Please read each static variable documentation to get details about the culling process.
  26045. * */
  26046. cullingStrategy: number;
  26047. /**
  26048. * Gets the number of facets in the mesh
  26049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26050. */
  26051. readonly facetNb: number;
  26052. /**
  26053. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26055. */
  26056. partitioningSubdivisions: number;
  26057. /**
  26058. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26059. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26061. */
  26062. partitioningBBoxRatio: number;
  26063. /**
  26064. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26065. * Works only for updatable meshes.
  26066. * Doesn't work with multi-materials
  26067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26068. */
  26069. mustDepthSortFacets: boolean;
  26070. /**
  26071. * The location (Vector3) where the facet depth sort must be computed from.
  26072. * By default, the active camera position.
  26073. * Used only when facet depth sort is enabled
  26074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26075. */
  26076. facetDepthSortFrom: Vector3;
  26077. /**
  26078. * gets a boolean indicating if facetData is enabled
  26079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26080. */
  26081. readonly isFacetDataEnabled: boolean;
  26082. /** @hidden */
  26083. _updateNonUniformScalingState(value: boolean): boolean;
  26084. /**
  26085. * An event triggered when this mesh collides with another one
  26086. */
  26087. onCollideObservable: Observable<AbstractMesh>;
  26088. /** Set a function to call when this mesh collides with another one */
  26089. onCollide: () => void;
  26090. /**
  26091. * An event triggered when the collision's position changes
  26092. */
  26093. onCollisionPositionChangeObservable: Observable<Vector3>;
  26094. /** Set a function to call when the collision's position changes */
  26095. onCollisionPositionChange: () => void;
  26096. /**
  26097. * An event triggered when material is changed
  26098. */
  26099. onMaterialChangedObservable: Observable<AbstractMesh>;
  26100. /**
  26101. * Gets or sets the orientation for POV movement & rotation
  26102. */
  26103. definedFacingForward: boolean;
  26104. /** @hidden */
  26105. _occlusionQuery: Nullable<WebGLQuery>;
  26106. /** @hidden */
  26107. _renderingGroup: Nullable<RenderingGroup>;
  26108. /**
  26109. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26110. */
  26111. /**
  26112. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26113. */
  26114. visibility: number;
  26115. /** Gets or sets the alpha index used to sort transparent meshes
  26116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26117. */
  26118. alphaIndex: number;
  26119. /**
  26120. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26121. */
  26122. isVisible: boolean;
  26123. /**
  26124. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26125. */
  26126. isPickable: boolean;
  26127. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26128. showSubMeshesBoundingBox: boolean;
  26129. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26131. */
  26132. isBlocker: boolean;
  26133. /**
  26134. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26135. */
  26136. enablePointerMoveEvents: boolean;
  26137. /**
  26138. * Specifies the rendering group id for this mesh (0 by default)
  26139. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26140. */
  26141. renderingGroupId: number;
  26142. private _material;
  26143. /** Gets or sets current material */
  26144. material: Nullable<Material>;
  26145. /**
  26146. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26147. * @see http://doc.babylonjs.com/babylon101/shadows
  26148. */
  26149. receiveShadows: boolean;
  26150. /** Defines color to use when rendering outline */
  26151. outlineColor: Color3;
  26152. /** Define width to use when rendering outline */
  26153. outlineWidth: number;
  26154. /** Defines color to use when rendering overlay */
  26155. overlayColor: Color3;
  26156. /** Defines alpha to use when rendering overlay */
  26157. overlayAlpha: number;
  26158. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26159. hasVertexAlpha: boolean;
  26160. /** 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) */
  26161. useVertexColors: boolean;
  26162. /**
  26163. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26164. */
  26165. computeBonesUsingShaders: boolean;
  26166. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26167. numBoneInfluencers: number;
  26168. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26169. applyFog: boolean;
  26170. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26171. useOctreeForRenderingSelection: boolean;
  26172. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26173. useOctreeForPicking: boolean;
  26174. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26175. useOctreeForCollisions: boolean;
  26176. /**
  26177. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26178. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26179. */
  26180. layerMask: number;
  26181. /**
  26182. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26183. */
  26184. alwaysSelectAsActiveMesh: boolean;
  26185. /**
  26186. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26187. */
  26188. doNotSyncBoundingInfo: boolean;
  26189. /**
  26190. * Gets or sets the current action manager
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26192. */
  26193. actionManager: Nullable<AbstractActionManager>;
  26194. private _meshCollisionData;
  26195. /**
  26196. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26198. */
  26199. ellipsoid: Vector3;
  26200. /**
  26201. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26203. */
  26204. ellipsoidOffset: Vector3;
  26205. /**
  26206. * Gets or sets a collision mask used to mask collisions (default is -1).
  26207. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26208. */
  26209. collisionMask: number;
  26210. /**
  26211. * Gets or sets the current collision group mask (-1 by default).
  26212. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26213. */
  26214. collisionGroup: number;
  26215. /**
  26216. * Defines edge width used when edgesRenderer is enabled
  26217. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26218. */
  26219. edgesWidth: number;
  26220. /**
  26221. * Defines edge color used when edgesRenderer is enabled
  26222. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26223. */
  26224. edgesColor: Color4;
  26225. /** @hidden */
  26226. _edgesRenderer: Nullable<IEdgesRenderer>;
  26227. /** @hidden */
  26228. _masterMesh: Nullable<AbstractMesh>;
  26229. /** @hidden */
  26230. _boundingInfo: Nullable<BoundingInfo>;
  26231. /** @hidden */
  26232. _renderId: number;
  26233. /**
  26234. * Gets or sets the list of subMeshes
  26235. * @see http://doc.babylonjs.com/how_to/multi_materials
  26236. */
  26237. subMeshes: SubMesh[];
  26238. /** @hidden */
  26239. _intersectionsInProgress: AbstractMesh[];
  26240. /** @hidden */
  26241. _unIndexed: boolean;
  26242. /** @hidden */
  26243. _lightSources: Light[];
  26244. /** Gets the list of lights affecting that mesh */
  26245. readonly lightSources: Light[];
  26246. /** @hidden */
  26247. readonly _positions: Nullable<Vector3[]>;
  26248. /** @hidden */
  26249. _waitingData: {
  26250. lods: Nullable<any>;
  26251. actions: Nullable<any>;
  26252. freezeWorldMatrix: Nullable<boolean>;
  26253. };
  26254. /** @hidden */
  26255. _bonesTransformMatrices: Nullable<Float32Array>;
  26256. /** @hidden */
  26257. _transformMatrixTexture: Nullable<RawTexture>;
  26258. /**
  26259. * Gets or sets a skeleton to apply skining transformations
  26260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26261. */
  26262. skeleton: Nullable<Skeleton>;
  26263. /**
  26264. * An event triggered when the mesh is rebuilt.
  26265. */
  26266. onRebuildObservable: Observable<AbstractMesh>;
  26267. /**
  26268. * Creates a new AbstractMesh
  26269. * @param name defines the name of the mesh
  26270. * @param scene defines the hosting scene
  26271. */
  26272. constructor(name: string, scene?: Nullable<Scene>);
  26273. /**
  26274. * Returns the string "AbstractMesh"
  26275. * @returns "AbstractMesh"
  26276. */
  26277. getClassName(): string;
  26278. /**
  26279. * Gets a string representation of the current mesh
  26280. * @param fullDetails defines a boolean indicating if full details must be included
  26281. * @returns a string representation of the current mesh
  26282. */
  26283. toString(fullDetails?: boolean): string;
  26284. /**
  26285. * @hidden
  26286. */
  26287. protected _getEffectiveParent(): Nullable<Node>;
  26288. /** @hidden */
  26289. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26290. /** @hidden */
  26291. _rebuild(): void;
  26292. /** @hidden */
  26293. _resyncLightSources(): void;
  26294. /** @hidden */
  26295. _resyncLighSource(light: Light): void;
  26296. /** @hidden */
  26297. _unBindEffect(): void;
  26298. /** @hidden */
  26299. _removeLightSource(light: Light, dispose: boolean): void;
  26300. private _markSubMeshesAsDirty;
  26301. /** @hidden */
  26302. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26303. /** @hidden */
  26304. _markSubMeshesAsAttributesDirty(): void;
  26305. /** @hidden */
  26306. _markSubMeshesAsMiscDirty(): void;
  26307. /**
  26308. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26309. */
  26310. scaling: Vector3;
  26311. /**
  26312. * Returns true if the mesh is blocked. Implemented by child classes
  26313. */
  26314. readonly isBlocked: boolean;
  26315. /**
  26316. * Returns the mesh itself by default. Implemented by child classes
  26317. * @param camera defines the camera to use to pick the right LOD level
  26318. * @returns the currentAbstractMesh
  26319. */
  26320. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26321. /**
  26322. * Returns 0 by default. Implemented by child classes
  26323. * @returns an integer
  26324. */
  26325. getTotalVertices(): number;
  26326. /**
  26327. * Returns a positive integer : the total number of indices in this mesh geometry.
  26328. * @returns the numner of indices or zero if the mesh has no geometry.
  26329. */
  26330. getTotalIndices(): number;
  26331. /**
  26332. * Returns null by default. Implemented by child classes
  26333. * @returns null
  26334. */
  26335. getIndices(): Nullable<IndicesArray>;
  26336. /**
  26337. * Returns the array of the requested vertex data kind. Implemented by child classes
  26338. * @param kind defines the vertex data kind to use
  26339. * @returns null
  26340. */
  26341. getVerticesData(kind: string): Nullable<FloatArray>;
  26342. /**
  26343. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26344. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26345. * Note that a new underlying VertexBuffer object is created each call.
  26346. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26347. * @param kind defines vertex data kind:
  26348. * * VertexBuffer.PositionKind
  26349. * * VertexBuffer.UVKind
  26350. * * VertexBuffer.UV2Kind
  26351. * * VertexBuffer.UV3Kind
  26352. * * VertexBuffer.UV4Kind
  26353. * * VertexBuffer.UV5Kind
  26354. * * VertexBuffer.UV6Kind
  26355. * * VertexBuffer.ColorKind
  26356. * * VertexBuffer.MatricesIndicesKind
  26357. * * VertexBuffer.MatricesIndicesExtraKind
  26358. * * VertexBuffer.MatricesWeightsKind
  26359. * * VertexBuffer.MatricesWeightsExtraKind
  26360. * @param data defines the data source
  26361. * @param updatable defines if the data must be flagged as updatable (or static)
  26362. * @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
  26363. * @returns the current mesh
  26364. */
  26365. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26366. /**
  26367. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26368. * If the mesh has no geometry, it is simply returned as it is.
  26369. * @param kind defines vertex data kind:
  26370. * * VertexBuffer.PositionKind
  26371. * * VertexBuffer.UVKind
  26372. * * VertexBuffer.UV2Kind
  26373. * * VertexBuffer.UV3Kind
  26374. * * VertexBuffer.UV4Kind
  26375. * * VertexBuffer.UV5Kind
  26376. * * VertexBuffer.UV6Kind
  26377. * * VertexBuffer.ColorKind
  26378. * * VertexBuffer.MatricesIndicesKind
  26379. * * VertexBuffer.MatricesIndicesExtraKind
  26380. * * VertexBuffer.MatricesWeightsKind
  26381. * * VertexBuffer.MatricesWeightsExtraKind
  26382. * @param data defines the data source
  26383. * @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
  26384. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26385. * @returns the current mesh
  26386. */
  26387. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26388. /**
  26389. * Sets the mesh indices,
  26390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26391. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26392. * @param totalVertices Defines the total number of vertices
  26393. * @returns the current mesh
  26394. */
  26395. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26396. /**
  26397. * Gets a boolean indicating if specific vertex data is present
  26398. * @param kind defines the vertex data kind to use
  26399. * @returns true is data kind is present
  26400. */
  26401. isVerticesDataPresent(kind: string): boolean;
  26402. /**
  26403. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26404. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26405. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26406. * @returns a BoundingInfo
  26407. */
  26408. getBoundingInfo(): BoundingInfo;
  26409. /**
  26410. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26411. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26412. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26413. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26414. * @returns the current mesh
  26415. */
  26416. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26417. /**
  26418. * Overwrite the current bounding info
  26419. * @param boundingInfo defines the new bounding info
  26420. * @returns the current mesh
  26421. */
  26422. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26423. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26424. readonly useBones: boolean;
  26425. /** @hidden */
  26426. _preActivate(): void;
  26427. /** @hidden */
  26428. _preActivateForIntermediateRendering(renderId: number): void;
  26429. /** @hidden */
  26430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26431. /** @hidden */
  26432. _postActivate(): void;
  26433. /** @hidden */
  26434. _freeze(): void;
  26435. /** @hidden */
  26436. _unFreeze(): void;
  26437. /**
  26438. * Gets the current world matrix
  26439. * @returns a Matrix
  26440. */
  26441. getWorldMatrix(): Matrix;
  26442. /** @hidden */
  26443. _getWorldMatrixDeterminant(): number;
  26444. /**
  26445. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26446. */
  26447. readonly isAnInstance: boolean;
  26448. /**
  26449. * Gets a boolean indicating if this mesh has instances
  26450. */
  26451. readonly hasInstances: boolean;
  26452. /**
  26453. * Perform relative position change from the point of view of behind the front of the mesh.
  26454. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26455. * Supports definition of mesh facing forward or backward
  26456. * @param amountRight defines the distance on the right axis
  26457. * @param amountUp defines the distance on the up axis
  26458. * @param amountForward defines the distance on the forward axis
  26459. * @returns the current mesh
  26460. */
  26461. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26462. /**
  26463. * Calculate relative position change from the point of view of behind the front of the mesh.
  26464. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26465. * Supports definition of mesh facing forward or backward
  26466. * @param amountRight defines the distance on the right axis
  26467. * @param amountUp defines the distance on the up axis
  26468. * @param amountForward defines the distance on the forward axis
  26469. * @returns the new displacement vector
  26470. */
  26471. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26472. /**
  26473. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26474. * Supports definition of mesh facing forward or backward
  26475. * @param flipBack defines the flip
  26476. * @param twirlClockwise defines the twirl
  26477. * @param tiltRight defines the tilt
  26478. * @returns the current mesh
  26479. */
  26480. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26481. /**
  26482. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26483. * Supports definition of mesh facing forward or backward.
  26484. * @param flipBack defines the flip
  26485. * @param twirlClockwise defines the twirl
  26486. * @param tiltRight defines the tilt
  26487. * @returns the new rotation vector
  26488. */
  26489. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26490. /**
  26491. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26492. * This means the mesh underlying bounding box and sphere are recomputed.
  26493. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26494. * @returns the current mesh
  26495. */
  26496. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26497. /** @hidden */
  26498. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26499. /** @hidden */
  26500. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26501. /** @hidden */
  26502. _updateBoundingInfo(): AbstractMesh;
  26503. /** @hidden */
  26504. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26505. /** @hidden */
  26506. protected _afterComputeWorldMatrix(): void;
  26507. /** @hidden */
  26508. readonly _effectiveMesh: AbstractMesh;
  26509. /**
  26510. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26511. * A mesh is in the frustum if its bounding box intersects the frustum
  26512. * @param frustumPlanes defines the frustum to test
  26513. * @returns true if the mesh is in the frustum planes
  26514. */
  26515. isInFrustum(frustumPlanes: Plane[]): boolean;
  26516. /**
  26517. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26518. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26519. * @param frustumPlanes defines the frustum to test
  26520. * @returns true if the mesh is completely in the frustum planes
  26521. */
  26522. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26523. /**
  26524. * True if the mesh intersects another mesh or a SolidParticle object
  26525. * @param mesh defines a target mesh or SolidParticle to test
  26526. * @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)
  26527. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26528. * @returns true if there is an intersection
  26529. */
  26530. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26531. /**
  26532. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26533. * @param point defines the point to test
  26534. * @returns true if there is an intersection
  26535. */
  26536. intersectsPoint(point: Vector3): boolean;
  26537. /**
  26538. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26540. */
  26541. checkCollisions: boolean;
  26542. /**
  26543. * Gets Collider object used to compute collisions (not physics)
  26544. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26545. */
  26546. readonly collider: Nullable<Collider>;
  26547. /**
  26548. * Move the mesh using collision engine
  26549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26550. * @param displacement defines the requested displacement vector
  26551. * @returns the current mesh
  26552. */
  26553. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26554. private _onCollisionPositionChange;
  26555. /** @hidden */
  26556. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26557. /** @hidden */
  26558. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26559. /** @hidden */
  26560. _checkCollision(collider: Collider): AbstractMesh;
  26561. /** @hidden */
  26562. _generatePointsArray(): boolean;
  26563. /**
  26564. * Checks if the passed Ray intersects with the mesh
  26565. * @param ray defines the ray to use
  26566. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26568. * @returns the picking info
  26569. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26570. */
  26571. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26572. /**
  26573. * Clones the current mesh
  26574. * @param name defines the mesh name
  26575. * @param newParent defines the new mesh parent
  26576. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26577. * @returns the new mesh
  26578. */
  26579. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26580. /**
  26581. * Disposes all the submeshes of the current meshnp
  26582. * @returns the current mesh
  26583. */
  26584. releaseSubMeshes(): AbstractMesh;
  26585. /**
  26586. * Releases resources associated with this abstract mesh.
  26587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26589. */
  26590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26591. /**
  26592. * Adds the passed mesh as a child to the current mesh
  26593. * @param mesh defines the child mesh
  26594. * @returns the current mesh
  26595. */
  26596. addChild(mesh: AbstractMesh): AbstractMesh;
  26597. /**
  26598. * Removes the passed mesh from the current mesh children list
  26599. * @param mesh defines the child mesh
  26600. * @returns the current mesh
  26601. */
  26602. removeChild(mesh: AbstractMesh): AbstractMesh;
  26603. /** @hidden */
  26604. private _initFacetData;
  26605. /**
  26606. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26607. * This method can be called within the render loop.
  26608. * 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
  26609. * @returns the current mesh
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26611. */
  26612. updateFacetData(): AbstractMesh;
  26613. /**
  26614. * Returns the facetLocalNormals array.
  26615. * The normals are expressed in the mesh local spac
  26616. * @returns an array of Vector3
  26617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26618. */
  26619. getFacetLocalNormals(): Vector3[];
  26620. /**
  26621. * Returns the facetLocalPositions array.
  26622. * The facet positions are expressed in the mesh local space
  26623. * @returns an array of Vector3
  26624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26625. */
  26626. getFacetLocalPositions(): Vector3[];
  26627. /**
  26628. * Returns the facetLocalPartioning array
  26629. * @returns an array of array of numbers
  26630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26631. */
  26632. getFacetLocalPartitioning(): number[][];
  26633. /**
  26634. * Returns the i-th facet position in the world system.
  26635. * This method allocates a new Vector3 per call
  26636. * @param i defines the facet index
  26637. * @returns a new Vector3
  26638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26639. */
  26640. getFacetPosition(i: number): Vector3;
  26641. /**
  26642. * Sets the reference Vector3 with the i-th facet position in the world system
  26643. * @param i defines the facet index
  26644. * @param ref defines the target vector
  26645. * @returns the current mesh
  26646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26647. */
  26648. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26649. /**
  26650. * Returns the i-th facet normal in the world system.
  26651. * This method allocates a new Vector3 per call
  26652. * @param i defines the facet index
  26653. * @returns a new Vector3
  26654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26655. */
  26656. getFacetNormal(i: number): Vector3;
  26657. /**
  26658. * Sets the reference Vector3 with the i-th facet normal in the world system
  26659. * @param i defines the facet index
  26660. * @param ref defines the target vector
  26661. * @returns the current mesh
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26663. */
  26664. getFacetNormalToRef(i: number, ref: Vector3): this;
  26665. /**
  26666. * 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)
  26667. * @param x defines x coordinate
  26668. * @param y defines y coordinate
  26669. * @param z defines z coordinate
  26670. * @returns the array of facet indexes
  26671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26672. */
  26673. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26674. /**
  26675. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26676. * @param projected sets as the (x,y,z) world projection on the facet
  26677. * @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
  26678. * @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
  26679. * @param x defines x coordinate
  26680. * @param y defines y coordinate
  26681. * @param z defines z coordinate
  26682. * @returns the face index if found (or null instead)
  26683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26684. */
  26685. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26686. /**
  26687. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26688. * @param projected sets as the (x,y,z) local projection on the facet
  26689. * @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
  26690. * @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
  26691. * @param x defines x coordinate
  26692. * @param y defines y coordinate
  26693. * @param z defines z coordinate
  26694. * @returns the face index if found (or null instead)
  26695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26696. */
  26697. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26698. /**
  26699. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26700. * @returns the parameters
  26701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26702. */
  26703. getFacetDataParameters(): any;
  26704. /**
  26705. * Disables the feature FacetData and frees the related memory
  26706. * @returns the current mesh
  26707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26708. */
  26709. disableFacetData(): AbstractMesh;
  26710. /**
  26711. * Updates the AbstractMesh indices array
  26712. * @param indices defines the data source
  26713. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26714. * @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)
  26715. * @returns the current mesh
  26716. */
  26717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26718. /**
  26719. * Creates new normals data for the mesh
  26720. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26721. * @returns the current mesh
  26722. */
  26723. createNormals(updatable: boolean): AbstractMesh;
  26724. /**
  26725. * Align the mesh with a normal
  26726. * @param normal defines the normal to use
  26727. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26728. * @returns the current mesh
  26729. */
  26730. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26731. /** @hidden */
  26732. _checkOcclusionQuery(): boolean;
  26733. /**
  26734. * Disables the mesh edge rendering mode
  26735. * @returns the currentAbstractMesh
  26736. */
  26737. disableEdgesRendering(): AbstractMesh;
  26738. /**
  26739. * Enables the edge rendering mode on the mesh.
  26740. * This mode makes the mesh edges visible
  26741. * @param epsilon defines the maximal distance between two angles to detect a face
  26742. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26743. * @returns the currentAbstractMesh
  26744. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26745. */
  26746. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26747. }
  26748. }
  26749. declare module BABYLON {
  26750. /**
  26751. * Interface used to define ActionEvent
  26752. */
  26753. export interface IActionEvent {
  26754. /** The mesh or sprite that triggered the action */
  26755. source: any;
  26756. /** The X mouse cursor position at the time of the event */
  26757. pointerX: number;
  26758. /** The Y mouse cursor position at the time of the event */
  26759. pointerY: number;
  26760. /** The mesh that is currently pointed at (can be null) */
  26761. meshUnderPointer: Nullable<AbstractMesh>;
  26762. /** the original (browser) event that triggered the ActionEvent */
  26763. sourceEvent?: any;
  26764. /** additional data for the event */
  26765. additionalData?: any;
  26766. }
  26767. /**
  26768. * ActionEvent is the event being sent when an action is triggered.
  26769. */
  26770. export class ActionEvent implements IActionEvent {
  26771. /** The mesh or sprite that triggered the action */
  26772. source: any;
  26773. /** The X mouse cursor position at the time of the event */
  26774. pointerX: number;
  26775. /** The Y mouse cursor position at the time of the event */
  26776. pointerY: number;
  26777. /** The mesh that is currently pointed at (can be null) */
  26778. meshUnderPointer: Nullable<AbstractMesh>;
  26779. /** the original (browser) event that triggered the ActionEvent */
  26780. sourceEvent?: any;
  26781. /** additional data for the event */
  26782. additionalData?: any;
  26783. /**
  26784. * Creates a new ActionEvent
  26785. * @param source The mesh or sprite that triggered the action
  26786. * @param pointerX The X mouse cursor position at the time of the event
  26787. * @param pointerY The Y mouse cursor position at the time of the event
  26788. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26789. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26790. * @param additionalData additional data for the event
  26791. */
  26792. constructor(
  26793. /** The mesh or sprite that triggered the action */
  26794. source: any,
  26795. /** The X mouse cursor position at the time of the event */
  26796. pointerX: number,
  26797. /** The Y mouse cursor position at the time of the event */
  26798. pointerY: number,
  26799. /** The mesh that is currently pointed at (can be null) */
  26800. meshUnderPointer: Nullable<AbstractMesh>,
  26801. /** the original (browser) event that triggered the ActionEvent */
  26802. sourceEvent?: any,
  26803. /** additional data for the event */
  26804. additionalData?: any);
  26805. /**
  26806. * Helper function to auto-create an ActionEvent from a source mesh.
  26807. * @param source The source mesh that triggered the event
  26808. * @param evt The original (browser) event
  26809. * @param additionalData additional data for the event
  26810. * @returns the new ActionEvent
  26811. */
  26812. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26813. /**
  26814. * Helper function to auto-create an ActionEvent from a source sprite
  26815. * @param source The source sprite that triggered the event
  26816. * @param scene Scene associated with the sprite
  26817. * @param evt The original (browser) event
  26818. * @param additionalData additional data for the event
  26819. * @returns the new ActionEvent
  26820. */
  26821. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26822. /**
  26823. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26824. * @param scene the scene where the event occurred
  26825. * @param evt The original (browser) event
  26826. * @returns the new ActionEvent
  26827. */
  26828. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26829. /**
  26830. * Helper function to auto-create an ActionEvent from a primitive
  26831. * @param prim defines the target primitive
  26832. * @param pointerPos defines the pointer position
  26833. * @param evt The original (browser) event
  26834. * @param additionalData additional data for the event
  26835. * @returns the new ActionEvent
  26836. */
  26837. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26838. }
  26839. }
  26840. declare module BABYLON {
  26841. /**
  26842. * Abstract class used to decouple action Manager from scene and meshes.
  26843. * Do not instantiate.
  26844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26845. */
  26846. export abstract class AbstractActionManager implements IDisposable {
  26847. /** Gets the list of active triggers */
  26848. static Triggers: {
  26849. [key: string]: number;
  26850. };
  26851. /** Gets the cursor to use when hovering items */
  26852. hoverCursor: string;
  26853. /** Gets the list of actions */
  26854. actions: IAction[];
  26855. /**
  26856. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26857. */
  26858. isRecursive: boolean;
  26859. /**
  26860. * Releases all associated resources
  26861. */
  26862. abstract dispose(): void;
  26863. /**
  26864. * Does this action manager has pointer triggers
  26865. */
  26866. abstract readonly hasPointerTriggers: boolean;
  26867. /**
  26868. * Does this action manager has pick triggers
  26869. */
  26870. abstract readonly hasPickTriggers: boolean;
  26871. /**
  26872. * Process a specific trigger
  26873. * @param trigger defines the trigger to process
  26874. * @param evt defines the event details to be processed
  26875. */
  26876. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26877. /**
  26878. * Does this action manager handles actions of any of the given triggers
  26879. * @param triggers defines the triggers to be tested
  26880. * @return a boolean indicating whether one (or more) of the triggers is handled
  26881. */
  26882. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26883. /**
  26884. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26885. * speed.
  26886. * @param triggerA defines the trigger to be tested
  26887. * @param triggerB defines the trigger to be tested
  26888. * @return a boolean indicating whether one (or more) of the triggers is handled
  26889. */
  26890. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26891. /**
  26892. * Does this action manager handles actions of a given trigger
  26893. * @param trigger defines the trigger to be tested
  26894. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26895. * @return whether the trigger is handled
  26896. */
  26897. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26898. /**
  26899. * Serialize this manager to a JSON object
  26900. * @param name defines the property name to store this manager
  26901. * @returns a JSON representation of this manager
  26902. */
  26903. abstract serialize(name: string): any;
  26904. /**
  26905. * Registers an action to this action manager
  26906. * @param action defines the action to be registered
  26907. * @return the action amended (prepared) after registration
  26908. */
  26909. abstract registerAction(action: IAction): Nullable<IAction>;
  26910. /**
  26911. * Unregisters an action to this action manager
  26912. * @param action defines the action to be unregistered
  26913. * @return a boolean indicating whether the action has been unregistered
  26914. */
  26915. abstract unregisterAction(action: IAction): Boolean;
  26916. /**
  26917. * Does exist one action manager with at least one trigger
  26918. **/
  26919. static readonly HasTriggers: boolean;
  26920. /**
  26921. * Does exist one action manager with at least one pick trigger
  26922. **/
  26923. static readonly HasPickTriggers: boolean;
  26924. /**
  26925. * Does exist one action manager that handles actions of a given trigger
  26926. * @param trigger defines the trigger to be tested
  26927. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26928. **/
  26929. static HasSpecificTrigger(trigger: number): boolean;
  26930. }
  26931. }
  26932. declare module BABYLON {
  26933. /**
  26934. * Defines how a node can be built from a string name.
  26935. */
  26936. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26937. /**
  26938. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26939. */
  26940. export class Node implements IBehaviorAware<Node> {
  26941. /** @hidden */
  26942. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26943. private static _NodeConstructors;
  26944. /**
  26945. * Add a new node constructor
  26946. * @param type defines the type name of the node to construct
  26947. * @param constructorFunc defines the constructor function
  26948. */
  26949. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26950. /**
  26951. * Returns a node constructor based on type name
  26952. * @param type defines the type name
  26953. * @param name defines the new node name
  26954. * @param scene defines the hosting scene
  26955. * @param options defines optional options to transmit to constructors
  26956. * @returns the new constructor or null
  26957. */
  26958. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26959. /**
  26960. * Gets or sets the name of the node
  26961. */
  26962. name: string;
  26963. /**
  26964. * Gets or sets the id of the node
  26965. */
  26966. id: string;
  26967. /**
  26968. * Gets or sets the unique id of the node
  26969. */
  26970. uniqueId: number;
  26971. /**
  26972. * Gets or sets a string used to store user defined state for the node
  26973. */
  26974. state: string;
  26975. /**
  26976. * Gets or sets an object used to store user defined information for the node
  26977. */
  26978. metadata: any;
  26979. /**
  26980. * For internal use only. Please do not use.
  26981. */
  26982. reservedDataStore: any;
  26983. /**
  26984. * List of inspectable custom properties (used by the Inspector)
  26985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26986. */
  26987. inspectableCustomProperties: IInspectable[];
  26988. private _doNotSerialize;
  26989. /**
  26990. * Gets or sets a boolean used to define if the node must be serialized
  26991. */
  26992. doNotSerialize: boolean;
  26993. /** @hidden */
  26994. _isDisposed: boolean;
  26995. /**
  26996. * Gets a list of Animations associated with the node
  26997. */
  26998. animations: Animation[];
  26999. protected _ranges: {
  27000. [name: string]: Nullable<AnimationRange>;
  27001. };
  27002. /**
  27003. * Callback raised when the node is ready to be used
  27004. */
  27005. onReady: Nullable<(node: Node) => void>;
  27006. private _isEnabled;
  27007. private _isParentEnabled;
  27008. private _isReady;
  27009. /** @hidden */
  27010. _currentRenderId: number;
  27011. private _parentUpdateId;
  27012. /** @hidden */
  27013. _childUpdateId: number;
  27014. /** @hidden */
  27015. _waitingParentId: Nullable<string>;
  27016. /** @hidden */
  27017. _scene: Scene;
  27018. /** @hidden */
  27019. _cache: any;
  27020. private _parentNode;
  27021. private _children;
  27022. /** @hidden */
  27023. _worldMatrix: Matrix;
  27024. /** @hidden */
  27025. _worldMatrixDeterminant: number;
  27026. /** @hidden */
  27027. _worldMatrixDeterminantIsDirty: boolean;
  27028. /** @hidden */
  27029. private _sceneRootNodesIndex;
  27030. /**
  27031. * Gets a boolean indicating if the node has been disposed
  27032. * @returns true if the node was disposed
  27033. */
  27034. isDisposed(): boolean;
  27035. /**
  27036. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27037. * @see https://doc.babylonjs.com/how_to/parenting
  27038. */
  27039. parent: Nullable<Node>;
  27040. /** @hidden */
  27041. _addToSceneRootNodes(): void;
  27042. /** @hidden */
  27043. _removeFromSceneRootNodes(): void;
  27044. private _animationPropertiesOverride;
  27045. /**
  27046. * Gets or sets the animation properties override
  27047. */
  27048. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27049. /**
  27050. * Gets a string idenfifying the name of the class
  27051. * @returns "Node" string
  27052. */
  27053. getClassName(): string;
  27054. /** @hidden */
  27055. readonly _isNode: boolean;
  27056. /**
  27057. * An event triggered when the mesh is disposed
  27058. */
  27059. onDisposeObservable: Observable<Node>;
  27060. private _onDisposeObserver;
  27061. /**
  27062. * Sets a callback that will be raised when the node will be disposed
  27063. */
  27064. onDispose: () => void;
  27065. /**
  27066. * Creates a new Node
  27067. * @param name the name and id to be given to this node
  27068. * @param scene the scene this node will be added to
  27069. */
  27070. constructor(name: string, scene?: Nullable<Scene>);
  27071. /**
  27072. * Gets the scene of the node
  27073. * @returns a scene
  27074. */
  27075. getScene(): Scene;
  27076. /**
  27077. * Gets the engine of the node
  27078. * @returns a Engine
  27079. */
  27080. getEngine(): Engine;
  27081. private _behaviors;
  27082. /**
  27083. * Attach a behavior to the node
  27084. * @see http://doc.babylonjs.com/features/behaviour
  27085. * @param behavior defines the behavior to attach
  27086. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27087. * @returns the current Node
  27088. */
  27089. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27090. /**
  27091. * Remove an attached behavior
  27092. * @see http://doc.babylonjs.com/features/behaviour
  27093. * @param behavior defines the behavior to attach
  27094. * @returns the current Node
  27095. */
  27096. removeBehavior(behavior: Behavior<Node>): Node;
  27097. /**
  27098. * Gets the list of attached behaviors
  27099. * @see http://doc.babylonjs.com/features/behaviour
  27100. */
  27101. readonly behaviors: Behavior<Node>[];
  27102. /**
  27103. * Gets an attached behavior by name
  27104. * @param name defines the name of the behavior to look for
  27105. * @see http://doc.babylonjs.com/features/behaviour
  27106. * @returns null if behavior was not found else the requested behavior
  27107. */
  27108. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27109. /**
  27110. * Returns the latest update of the World matrix
  27111. * @returns a Matrix
  27112. */
  27113. getWorldMatrix(): Matrix;
  27114. /** @hidden */
  27115. _getWorldMatrixDeterminant(): number;
  27116. /**
  27117. * Returns directly the latest state of the mesh World matrix.
  27118. * A Matrix is returned.
  27119. */
  27120. readonly worldMatrixFromCache: Matrix;
  27121. /** @hidden */
  27122. _initCache(): void;
  27123. /** @hidden */
  27124. updateCache(force?: boolean): void;
  27125. /** @hidden */
  27126. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27127. /** @hidden */
  27128. _updateCache(ignoreParentClass?: boolean): void;
  27129. /** @hidden */
  27130. _isSynchronized(): boolean;
  27131. /** @hidden */
  27132. _markSyncedWithParent(): void;
  27133. /** @hidden */
  27134. isSynchronizedWithParent(): boolean;
  27135. /** @hidden */
  27136. isSynchronized(): boolean;
  27137. /**
  27138. * Is this node ready to be used/rendered
  27139. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27140. * @return true if the node is ready
  27141. */
  27142. isReady(completeCheck?: boolean): boolean;
  27143. /**
  27144. * Is this node enabled?
  27145. * 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
  27146. * @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
  27147. * @return whether this node (and its parent) is enabled
  27148. */
  27149. isEnabled(checkAncestors?: boolean): boolean;
  27150. /** @hidden */
  27151. protected _syncParentEnabledState(): void;
  27152. /**
  27153. * Set the enabled state of this node
  27154. * @param value defines the new enabled state
  27155. */
  27156. setEnabled(value: boolean): void;
  27157. /**
  27158. * Is this node a descendant of the given node?
  27159. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27160. * @param ancestor defines the parent node to inspect
  27161. * @returns a boolean indicating if this node is a descendant of the given node
  27162. */
  27163. isDescendantOf(ancestor: Node): boolean;
  27164. /** @hidden */
  27165. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27166. /**
  27167. * Will return all nodes that have this node as ascendant
  27168. * @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
  27169. * @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
  27170. * @return all children nodes of all types
  27171. */
  27172. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27173. /**
  27174. * Get all child-meshes of this node
  27175. * @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)
  27176. * @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
  27177. * @returns an array of AbstractMesh
  27178. */
  27179. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27180. /**
  27181. * Get all direct children of this node
  27182. * @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
  27183. * @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)
  27184. * @returns an array of Node
  27185. */
  27186. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27187. /** @hidden */
  27188. _setReady(state: boolean): void;
  27189. /**
  27190. * Get an animation by name
  27191. * @param name defines the name of the animation to look for
  27192. * @returns null if not found else the requested animation
  27193. */
  27194. getAnimationByName(name: string): Nullable<Animation>;
  27195. /**
  27196. * Creates an animation range for this node
  27197. * @param name defines the name of the range
  27198. * @param from defines the starting key
  27199. * @param to defines the end key
  27200. */
  27201. createAnimationRange(name: string, from: number, to: number): void;
  27202. /**
  27203. * Delete a specific animation range
  27204. * @param name defines the name of the range to delete
  27205. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27206. */
  27207. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27208. /**
  27209. * Get an animation range by name
  27210. * @param name defines the name of the animation range to look for
  27211. * @returns null if not found else the requested animation range
  27212. */
  27213. getAnimationRange(name: string): Nullable<AnimationRange>;
  27214. /**
  27215. * Gets the list of all animation ranges defined on this node
  27216. * @returns an array
  27217. */
  27218. getAnimationRanges(): Nullable<AnimationRange>[];
  27219. /**
  27220. * Will start the animation sequence
  27221. * @param name defines the range frames for animation sequence
  27222. * @param loop defines if the animation should loop (false by default)
  27223. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27224. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27225. * @returns the object created for this animation. If range does not exist, it will return null
  27226. */
  27227. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27228. /**
  27229. * Serialize animation ranges into a JSON compatible object
  27230. * @returns serialization object
  27231. */
  27232. serializeAnimationRanges(): any;
  27233. /**
  27234. * Computes the world matrix of the node
  27235. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27236. * @returns the world matrix
  27237. */
  27238. computeWorldMatrix(force?: boolean): Matrix;
  27239. /**
  27240. * Releases resources associated with this node.
  27241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27243. */
  27244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27245. /**
  27246. * Parse animation range data from a serialization object and store them into a given node
  27247. * @param node defines where to store the animation ranges
  27248. * @param parsedNode defines the serialization object to read data from
  27249. * @param scene defines the hosting scene
  27250. */
  27251. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27252. /**
  27253. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27254. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27255. * @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
  27256. * @returns the new bounding vectors
  27257. */
  27258. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27259. min: Vector3;
  27260. max: Vector3;
  27261. };
  27262. }
  27263. }
  27264. declare module BABYLON {
  27265. /**
  27266. * @hidden
  27267. */
  27268. export class _IAnimationState {
  27269. key: number;
  27270. repeatCount: number;
  27271. workValue?: any;
  27272. loopMode?: number;
  27273. offsetValue?: any;
  27274. highLimitValue?: any;
  27275. }
  27276. /**
  27277. * Class used to store any kind of animation
  27278. */
  27279. export class Animation {
  27280. /**Name of the animation */
  27281. name: string;
  27282. /**Property to animate */
  27283. targetProperty: string;
  27284. /**The frames per second of the animation */
  27285. framePerSecond: number;
  27286. /**The data type of the animation */
  27287. dataType: number;
  27288. /**The loop mode of the animation */
  27289. loopMode?: number | undefined;
  27290. /**Specifies if blending should be enabled */
  27291. enableBlending?: boolean | undefined;
  27292. /**
  27293. * Use matrix interpolation instead of using direct key value when animating matrices
  27294. */
  27295. static AllowMatricesInterpolation: boolean;
  27296. /**
  27297. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27298. */
  27299. static AllowMatrixDecomposeForInterpolation: boolean;
  27300. /**
  27301. * Stores the key frames of the animation
  27302. */
  27303. private _keys;
  27304. /**
  27305. * Stores the easing function of the animation
  27306. */
  27307. private _easingFunction;
  27308. /**
  27309. * @hidden Internal use only
  27310. */
  27311. _runtimeAnimations: RuntimeAnimation[];
  27312. /**
  27313. * The set of event that will be linked to this animation
  27314. */
  27315. private _events;
  27316. /**
  27317. * Stores an array of target property paths
  27318. */
  27319. targetPropertyPath: string[];
  27320. /**
  27321. * Stores the blending speed of the animation
  27322. */
  27323. blendingSpeed: number;
  27324. /**
  27325. * Stores the animation ranges for the animation
  27326. */
  27327. private _ranges;
  27328. /**
  27329. * @hidden Internal use
  27330. */
  27331. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27332. /**
  27333. * Sets up an animation
  27334. * @param property The property to animate
  27335. * @param animationType The animation type to apply
  27336. * @param framePerSecond The frames per second of the animation
  27337. * @param easingFunction The easing function used in the animation
  27338. * @returns The created animation
  27339. */
  27340. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27341. /**
  27342. * Create and start an animation on a node
  27343. * @param name defines the name of the global animation that will be run on all nodes
  27344. * @param node defines the root node where the animation will take place
  27345. * @param targetProperty defines property to animate
  27346. * @param framePerSecond defines the number of frame per second yo use
  27347. * @param totalFrame defines the number of frames in total
  27348. * @param from defines the initial value
  27349. * @param to defines the final value
  27350. * @param loopMode defines which loop mode you want to use (off by default)
  27351. * @param easingFunction defines the easing function to use (linear by default)
  27352. * @param onAnimationEnd defines the callback to call when animation end
  27353. * @returns the animatable created for this animation
  27354. */
  27355. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27356. /**
  27357. * Create and start an animation on a node and its descendants
  27358. * @param name defines the name of the global animation that will be run on all nodes
  27359. * @param node defines the root node where the animation will take place
  27360. * @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
  27361. * @param targetProperty defines property to animate
  27362. * @param framePerSecond defines the number of frame per second to use
  27363. * @param totalFrame defines the number of frames in total
  27364. * @param from defines the initial value
  27365. * @param to defines the final value
  27366. * @param loopMode defines which loop mode you want to use (off by default)
  27367. * @param easingFunction defines the easing function to use (linear by default)
  27368. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27369. * @returns the list of animatables created for all nodes
  27370. * @example https://www.babylonjs-playground.com/#MH0VLI
  27371. */
  27372. 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[]>;
  27373. /**
  27374. * Creates a new animation, merges it with the existing animations and starts it
  27375. * @param name Name of the animation
  27376. * @param node Node which contains the scene that begins the animations
  27377. * @param targetProperty Specifies which property to animate
  27378. * @param framePerSecond The frames per second of the animation
  27379. * @param totalFrame The total number of frames
  27380. * @param from The frame at the beginning of the animation
  27381. * @param to The frame at the end of the animation
  27382. * @param loopMode Specifies the loop mode of the animation
  27383. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27384. * @param onAnimationEnd Callback to run once the animation is complete
  27385. * @returns Nullable animation
  27386. */
  27387. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27388. /**
  27389. * Transition property of an host to the target Value
  27390. * @param property The property to transition
  27391. * @param targetValue The target Value of the property
  27392. * @param host The object where the property to animate belongs
  27393. * @param scene Scene used to run the animation
  27394. * @param frameRate Framerate (in frame/s) to use
  27395. * @param transition The transition type we want to use
  27396. * @param duration The duration of the animation, in milliseconds
  27397. * @param onAnimationEnd Callback trigger at the end of the animation
  27398. * @returns Nullable animation
  27399. */
  27400. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27401. /**
  27402. * Return the array of runtime animations currently using this animation
  27403. */
  27404. readonly runtimeAnimations: RuntimeAnimation[];
  27405. /**
  27406. * Specifies if any of the runtime animations are currently running
  27407. */
  27408. readonly hasRunningRuntimeAnimations: boolean;
  27409. /**
  27410. * Initializes the animation
  27411. * @param name Name of the animation
  27412. * @param targetProperty Property to animate
  27413. * @param framePerSecond The frames per second of the animation
  27414. * @param dataType The data type of the animation
  27415. * @param loopMode The loop mode of the animation
  27416. * @param enableBlending Specifies if blending should be enabled
  27417. */
  27418. constructor(
  27419. /**Name of the animation */
  27420. name: string,
  27421. /**Property to animate */
  27422. targetProperty: string,
  27423. /**The frames per second of the animation */
  27424. framePerSecond: number,
  27425. /**The data type of the animation */
  27426. dataType: number,
  27427. /**The loop mode of the animation */
  27428. loopMode?: number | undefined,
  27429. /**Specifies if blending should be enabled */
  27430. enableBlending?: boolean | undefined);
  27431. /**
  27432. * Converts the animation to a string
  27433. * @param fullDetails support for multiple levels of logging within scene loading
  27434. * @returns String form of the animation
  27435. */
  27436. toString(fullDetails?: boolean): string;
  27437. /**
  27438. * Add an event to this animation
  27439. * @param event Event to add
  27440. */
  27441. addEvent(event: AnimationEvent): void;
  27442. /**
  27443. * Remove all events found at the given frame
  27444. * @param frame The frame to remove events from
  27445. */
  27446. removeEvents(frame: number): void;
  27447. /**
  27448. * Retrieves all the events from the animation
  27449. * @returns Events from the animation
  27450. */
  27451. getEvents(): AnimationEvent[];
  27452. /**
  27453. * Creates an animation range
  27454. * @param name Name of the animation range
  27455. * @param from Starting frame of the animation range
  27456. * @param to Ending frame of the animation
  27457. */
  27458. createRange(name: string, from: number, to: number): void;
  27459. /**
  27460. * Deletes an animation range by name
  27461. * @param name Name of the animation range to delete
  27462. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27463. */
  27464. deleteRange(name: string, deleteFrames?: boolean): void;
  27465. /**
  27466. * Gets the animation range by name, or null if not defined
  27467. * @param name Name of the animation range
  27468. * @returns Nullable animation range
  27469. */
  27470. getRange(name: string): Nullable<AnimationRange>;
  27471. /**
  27472. * Gets the key frames from the animation
  27473. * @returns The key frames of the animation
  27474. */
  27475. getKeys(): Array<IAnimationKey>;
  27476. /**
  27477. * Gets the highest frame rate of the animation
  27478. * @returns Highest frame rate of the animation
  27479. */
  27480. getHighestFrame(): number;
  27481. /**
  27482. * Gets the easing function of the animation
  27483. * @returns Easing function of the animation
  27484. */
  27485. getEasingFunction(): IEasingFunction;
  27486. /**
  27487. * Sets the easing function of the animation
  27488. * @param easingFunction A custom mathematical formula for animation
  27489. */
  27490. setEasingFunction(easingFunction: EasingFunction): void;
  27491. /**
  27492. * Interpolates a scalar linearly
  27493. * @param startValue Start value of the animation curve
  27494. * @param endValue End value of the animation curve
  27495. * @param gradient Scalar amount to interpolate
  27496. * @returns Interpolated scalar value
  27497. */
  27498. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27499. /**
  27500. * Interpolates a scalar cubically
  27501. * @param startValue Start value of the animation curve
  27502. * @param outTangent End tangent of the animation
  27503. * @param endValue End value of the animation curve
  27504. * @param inTangent Start tangent of the animation curve
  27505. * @param gradient Scalar amount to interpolate
  27506. * @returns Interpolated scalar value
  27507. */
  27508. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27509. /**
  27510. * Interpolates a quaternion using a spherical linear interpolation
  27511. * @param startValue Start value of the animation curve
  27512. * @param endValue End value of the animation curve
  27513. * @param gradient Scalar amount to interpolate
  27514. * @returns Interpolated quaternion value
  27515. */
  27516. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27517. /**
  27518. * Interpolates a quaternion cubically
  27519. * @param startValue Start value of the animation curve
  27520. * @param outTangent End tangent of the animation curve
  27521. * @param endValue End value of the animation curve
  27522. * @param inTangent Start tangent of the animation curve
  27523. * @param gradient Scalar amount to interpolate
  27524. * @returns Interpolated quaternion value
  27525. */
  27526. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27527. /**
  27528. * Interpolates a Vector3 linearl
  27529. * @param startValue Start value of the animation curve
  27530. * @param endValue End value of the animation curve
  27531. * @param gradient Scalar amount to interpolate
  27532. * @returns Interpolated scalar value
  27533. */
  27534. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27535. /**
  27536. * Interpolates a Vector3 cubically
  27537. * @param startValue Start value of the animation curve
  27538. * @param outTangent End tangent of the animation
  27539. * @param endValue End value of the animation curve
  27540. * @param inTangent Start tangent of the animation curve
  27541. * @param gradient Scalar amount to interpolate
  27542. * @returns InterpolatedVector3 value
  27543. */
  27544. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27545. /**
  27546. * Interpolates a Vector2 linearly
  27547. * @param startValue Start value of the animation curve
  27548. * @param endValue End value of the animation curve
  27549. * @param gradient Scalar amount to interpolate
  27550. * @returns Interpolated Vector2 value
  27551. */
  27552. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27553. /**
  27554. * Interpolates a Vector2 cubically
  27555. * @param startValue Start value of the animation curve
  27556. * @param outTangent End tangent of the animation
  27557. * @param endValue End value of the animation curve
  27558. * @param inTangent Start tangent of the animation curve
  27559. * @param gradient Scalar amount to interpolate
  27560. * @returns Interpolated Vector2 value
  27561. */
  27562. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27563. /**
  27564. * Interpolates a size linearly
  27565. * @param startValue Start value of the animation curve
  27566. * @param endValue End value of the animation curve
  27567. * @param gradient Scalar amount to interpolate
  27568. * @returns Interpolated Size value
  27569. */
  27570. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27571. /**
  27572. * Interpolates a Color3 linearly
  27573. * @param startValue Start value of the animation curve
  27574. * @param endValue End value of the animation curve
  27575. * @param gradient Scalar amount to interpolate
  27576. * @returns Interpolated Color3 value
  27577. */
  27578. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27579. /**
  27580. * Interpolates a Color4 linearly
  27581. * @param startValue Start value of the animation curve
  27582. * @param endValue End value of the animation curve
  27583. * @param gradient Scalar amount to interpolate
  27584. * @returns Interpolated Color3 value
  27585. */
  27586. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27587. /**
  27588. * @hidden Internal use only
  27589. */
  27590. _getKeyValue(value: any): any;
  27591. /**
  27592. * @hidden Internal use only
  27593. */
  27594. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27595. /**
  27596. * Defines the function to use to interpolate matrices
  27597. * @param startValue defines the start matrix
  27598. * @param endValue defines the end matrix
  27599. * @param gradient defines the gradient between both matrices
  27600. * @param result defines an optional target matrix where to store the interpolation
  27601. * @returns the interpolated matrix
  27602. */
  27603. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27604. /**
  27605. * Makes a copy of the animation
  27606. * @returns Cloned animation
  27607. */
  27608. clone(): Animation;
  27609. /**
  27610. * Sets the key frames of the animation
  27611. * @param values The animation key frames to set
  27612. */
  27613. setKeys(values: Array<IAnimationKey>): void;
  27614. /**
  27615. * Serializes the animation to an object
  27616. * @returns Serialized object
  27617. */
  27618. serialize(): any;
  27619. /**
  27620. * Float animation type
  27621. */
  27622. static readonly ANIMATIONTYPE_FLOAT: number;
  27623. /**
  27624. * Vector3 animation type
  27625. */
  27626. static readonly ANIMATIONTYPE_VECTOR3: number;
  27627. /**
  27628. * Quaternion animation type
  27629. */
  27630. static readonly ANIMATIONTYPE_QUATERNION: number;
  27631. /**
  27632. * Matrix animation type
  27633. */
  27634. static readonly ANIMATIONTYPE_MATRIX: number;
  27635. /**
  27636. * Color3 animation type
  27637. */
  27638. static readonly ANIMATIONTYPE_COLOR3: number;
  27639. /**
  27640. * Color3 animation type
  27641. */
  27642. static readonly ANIMATIONTYPE_COLOR4: number;
  27643. /**
  27644. * Vector2 animation type
  27645. */
  27646. static readonly ANIMATIONTYPE_VECTOR2: number;
  27647. /**
  27648. * Size animation type
  27649. */
  27650. static readonly ANIMATIONTYPE_SIZE: number;
  27651. /**
  27652. * Relative Loop Mode
  27653. */
  27654. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27655. /**
  27656. * Cycle Loop Mode
  27657. */
  27658. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27659. /**
  27660. * Constant Loop Mode
  27661. */
  27662. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27663. /** @hidden */
  27664. static _UniversalLerp(left: any, right: any, amount: number): any;
  27665. /**
  27666. * Parses an animation object and creates an animation
  27667. * @param parsedAnimation Parsed animation object
  27668. * @returns Animation object
  27669. */
  27670. static Parse(parsedAnimation: any): Animation;
  27671. /**
  27672. * Appends the serialized animations from the source animations
  27673. * @param source Source containing the animations
  27674. * @param destination Target to store the animations
  27675. */
  27676. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27677. }
  27678. }
  27679. declare module BABYLON {
  27680. /**
  27681. * Interface containing an array of animations
  27682. */
  27683. export interface IAnimatable {
  27684. /**
  27685. * Array of animations
  27686. */
  27687. animations: Nullable<Array<Animation>>;
  27688. }
  27689. }
  27690. declare module BABYLON {
  27691. /**
  27692. * This represents all the required information to add a fresnel effect on a material:
  27693. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27694. */
  27695. export class FresnelParameters {
  27696. private _isEnabled;
  27697. /**
  27698. * Define if the fresnel effect is enable or not.
  27699. */
  27700. isEnabled: boolean;
  27701. /**
  27702. * Define the color used on edges (grazing angle)
  27703. */
  27704. leftColor: Color3;
  27705. /**
  27706. * Define the color used on center
  27707. */
  27708. rightColor: Color3;
  27709. /**
  27710. * Define bias applied to computed fresnel term
  27711. */
  27712. bias: number;
  27713. /**
  27714. * Defined the power exponent applied to fresnel term
  27715. */
  27716. power: number;
  27717. /**
  27718. * Clones the current fresnel and its valuues
  27719. * @returns a clone fresnel configuration
  27720. */
  27721. clone(): FresnelParameters;
  27722. /**
  27723. * Serializes the current fresnel parameters to a JSON representation.
  27724. * @return the JSON serialization
  27725. */
  27726. serialize(): any;
  27727. /**
  27728. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27729. * @param parsedFresnelParameters Define the JSON representation
  27730. * @returns the parsed parameters
  27731. */
  27732. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27733. }
  27734. }
  27735. declare module BABYLON {
  27736. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27737. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27738. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27739. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27740. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27741. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27742. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27743. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27744. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27745. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27746. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27747. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27748. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27749. /**
  27750. * Decorator used to define property that can be serialized as reference to a camera
  27751. * @param sourceName defines the name of the property to decorate
  27752. */
  27753. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27754. /**
  27755. * Class used to help serialization objects
  27756. */
  27757. export class SerializationHelper {
  27758. /** @hidden */
  27759. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27760. /** @hidden */
  27761. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27762. /** @hidden */
  27763. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27764. /** @hidden */
  27765. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27766. /**
  27767. * Appends the serialized animations from the source animations
  27768. * @param source Source containing the animations
  27769. * @param destination Target to store the animations
  27770. */
  27771. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27772. /**
  27773. * Static function used to serialized a specific entity
  27774. * @param entity defines the entity to serialize
  27775. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27776. * @returns a JSON compatible object representing the serialization of the entity
  27777. */
  27778. static Serialize<T>(entity: T, serializationObject?: any): any;
  27779. /**
  27780. * Creates a new entity from a serialization data object
  27781. * @param creationFunction defines a function used to instanciated the new entity
  27782. * @param source defines the source serialization data
  27783. * @param scene defines the hosting scene
  27784. * @param rootUrl defines the root url for resources
  27785. * @returns a new entity
  27786. */
  27787. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27788. /**
  27789. * Clones an object
  27790. * @param creationFunction defines the function used to instanciate the new object
  27791. * @param source defines the source object
  27792. * @returns the cloned object
  27793. */
  27794. static Clone<T>(creationFunction: () => T, source: T): T;
  27795. /**
  27796. * Instanciates a new object based on a source one (some data will be shared between both object)
  27797. * @param creationFunction defines the function used to instanciate the new object
  27798. * @param source defines the source object
  27799. * @returns the new object
  27800. */
  27801. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27802. }
  27803. }
  27804. declare module BABYLON {
  27805. /**
  27806. * Class used to manipulate GUIDs
  27807. */
  27808. export class GUID {
  27809. /**
  27810. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27811. * Be aware Math.random() could cause collisions, but:
  27812. * "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"
  27813. * @returns a pseudo random id
  27814. */
  27815. static RandomId(): string;
  27816. }
  27817. }
  27818. declare module BABYLON {
  27819. /**
  27820. * Base class of all the textures in babylon.
  27821. * It groups all the common properties the materials, post process, lights... might need
  27822. * in order to make a correct use of the texture.
  27823. */
  27824. export class BaseTexture implements IAnimatable {
  27825. /**
  27826. * Default anisotropic filtering level for the application.
  27827. * It is set to 4 as a good tradeoff between perf and quality.
  27828. */
  27829. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27830. /**
  27831. * Gets or sets the unique id of the texture
  27832. */
  27833. uniqueId: number;
  27834. /**
  27835. * Define the name of the texture.
  27836. */
  27837. name: string;
  27838. /**
  27839. * Gets or sets an object used to store user defined information.
  27840. */
  27841. metadata: any;
  27842. /**
  27843. * For internal use only. Please do not use.
  27844. */
  27845. reservedDataStore: any;
  27846. private _hasAlpha;
  27847. /**
  27848. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27849. */
  27850. hasAlpha: boolean;
  27851. /**
  27852. * Defines if the alpha value should be determined via the rgb values.
  27853. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27854. */
  27855. getAlphaFromRGB: boolean;
  27856. /**
  27857. * Intensity or strength of the texture.
  27858. * It is commonly used by materials to fine tune the intensity of the texture
  27859. */
  27860. level: number;
  27861. /**
  27862. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27863. * This is part of the texture as textures usually maps to one uv set.
  27864. */
  27865. coordinatesIndex: number;
  27866. private _coordinatesMode;
  27867. /**
  27868. * How a texture is mapped.
  27869. *
  27870. * | Value | Type | Description |
  27871. * | ----- | ----------------------------------- | ----------- |
  27872. * | 0 | EXPLICIT_MODE | |
  27873. * | 1 | SPHERICAL_MODE | |
  27874. * | 2 | PLANAR_MODE | |
  27875. * | 3 | CUBIC_MODE | |
  27876. * | 4 | PROJECTION_MODE | |
  27877. * | 5 | SKYBOX_MODE | |
  27878. * | 6 | INVCUBIC_MODE | |
  27879. * | 7 | EQUIRECTANGULAR_MODE | |
  27880. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27881. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27882. */
  27883. coordinatesMode: number;
  27884. /**
  27885. * | Value | Type | Description |
  27886. * | ----- | ------------------ | ----------- |
  27887. * | 0 | CLAMP_ADDRESSMODE | |
  27888. * | 1 | WRAP_ADDRESSMODE | |
  27889. * | 2 | MIRROR_ADDRESSMODE | |
  27890. */
  27891. wrapU: number;
  27892. /**
  27893. * | Value | Type | Description |
  27894. * | ----- | ------------------ | ----------- |
  27895. * | 0 | CLAMP_ADDRESSMODE | |
  27896. * | 1 | WRAP_ADDRESSMODE | |
  27897. * | 2 | MIRROR_ADDRESSMODE | |
  27898. */
  27899. wrapV: number;
  27900. /**
  27901. * | Value | Type | Description |
  27902. * | ----- | ------------------ | ----------- |
  27903. * | 0 | CLAMP_ADDRESSMODE | |
  27904. * | 1 | WRAP_ADDRESSMODE | |
  27905. * | 2 | MIRROR_ADDRESSMODE | |
  27906. */
  27907. wrapR: number;
  27908. /**
  27909. * With compliant hardware and browser (supporting anisotropic filtering)
  27910. * this defines the level of anisotropic filtering in the texture.
  27911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27912. */
  27913. anisotropicFilteringLevel: number;
  27914. /**
  27915. * Define if the texture is a cube texture or if false a 2d texture.
  27916. */
  27917. isCube: boolean;
  27918. /**
  27919. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27920. */
  27921. is3D: boolean;
  27922. /**
  27923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27924. * HDR texture are usually stored in linear space.
  27925. * This only impacts the PBR and Background materials
  27926. */
  27927. gammaSpace: boolean;
  27928. /**
  27929. * Gets or sets whether or not the texture contains RGBD data.
  27930. */
  27931. isRGBD: boolean;
  27932. /**
  27933. * Is Z inverted in the texture (useful in a cube texture).
  27934. */
  27935. invertZ: boolean;
  27936. /**
  27937. * Are mip maps generated for this texture or not.
  27938. */
  27939. readonly noMipmap: boolean;
  27940. /**
  27941. * @hidden
  27942. */
  27943. lodLevelInAlpha: boolean;
  27944. /**
  27945. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27946. */
  27947. lodGenerationOffset: number;
  27948. /**
  27949. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27950. */
  27951. lodGenerationScale: number;
  27952. /**
  27953. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27954. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27955. * average roughness values.
  27956. */
  27957. linearSpecularLOD: boolean;
  27958. /**
  27959. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27960. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27961. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27962. */
  27963. irradianceTexture: Nullable<BaseTexture>;
  27964. /**
  27965. * Define if the texture is a render target.
  27966. */
  27967. isRenderTarget: boolean;
  27968. /**
  27969. * Define the unique id of the texture in the scene.
  27970. */
  27971. readonly uid: string;
  27972. /**
  27973. * Return a string representation of the texture.
  27974. * @returns the texture as a string
  27975. */
  27976. toString(): string;
  27977. /**
  27978. * Get the class name of the texture.
  27979. * @returns "BaseTexture"
  27980. */
  27981. getClassName(): string;
  27982. /**
  27983. * Define the list of animation attached to the texture.
  27984. */
  27985. animations: Animation[];
  27986. /**
  27987. * An event triggered when the texture is disposed.
  27988. */
  27989. onDisposeObservable: Observable<BaseTexture>;
  27990. private _onDisposeObserver;
  27991. /**
  27992. * Callback triggered when the texture has been disposed.
  27993. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27994. */
  27995. onDispose: () => void;
  27996. /**
  27997. * Define the current state of the loading sequence when in delayed load mode.
  27998. */
  27999. delayLoadState: number;
  28000. private _scene;
  28001. /** @hidden */
  28002. _texture: Nullable<InternalTexture>;
  28003. private _uid;
  28004. /**
  28005. * Define if the texture is preventinga material to render or not.
  28006. * If not and the texture is not ready, the engine will use a default black texture instead.
  28007. */
  28008. readonly isBlocking: boolean;
  28009. /**
  28010. * Instantiates a new BaseTexture.
  28011. * Base class of all the textures in babylon.
  28012. * It groups all the common properties the materials, post process, lights... might need
  28013. * in order to make a correct use of the texture.
  28014. * @param scene Define the scene the texture blongs to
  28015. */
  28016. constructor(scene: Nullable<Scene>);
  28017. /**
  28018. * Get the scene the texture belongs to.
  28019. * @returns the scene or null if undefined
  28020. */
  28021. getScene(): Nullable<Scene>;
  28022. /**
  28023. * Get the texture transform matrix used to offset tile the texture for istance.
  28024. * @returns the transformation matrix
  28025. */
  28026. getTextureMatrix(): Matrix;
  28027. /**
  28028. * Get the texture reflection matrix used to rotate/transform the reflection.
  28029. * @returns the reflection matrix
  28030. */
  28031. getReflectionTextureMatrix(): Matrix;
  28032. /**
  28033. * Get the underlying lower level texture from Babylon.
  28034. * @returns the insternal texture
  28035. */
  28036. getInternalTexture(): Nullable<InternalTexture>;
  28037. /**
  28038. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28039. * @returns true if ready or not blocking
  28040. */
  28041. isReadyOrNotBlocking(): boolean;
  28042. /**
  28043. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28044. * @returns true if fully ready
  28045. */
  28046. isReady(): boolean;
  28047. private _cachedSize;
  28048. /**
  28049. * Get the size of the texture.
  28050. * @returns the texture size.
  28051. */
  28052. getSize(): ISize;
  28053. /**
  28054. * Get the base size of the texture.
  28055. * It can be different from the size if the texture has been resized for POT for instance
  28056. * @returns the base size
  28057. */
  28058. getBaseSize(): ISize;
  28059. /**
  28060. * Update the sampling mode of the texture.
  28061. * Default is Trilinear mode.
  28062. *
  28063. * | Value | Type | Description |
  28064. * | ----- | ------------------ | ----------- |
  28065. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28066. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28067. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28068. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28069. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28070. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28071. * | 7 | NEAREST_LINEAR | |
  28072. * | 8 | NEAREST_NEAREST | |
  28073. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28074. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28075. * | 11 | LINEAR_LINEAR | |
  28076. * | 12 | LINEAR_NEAREST | |
  28077. *
  28078. * > _mag_: magnification filter (close to the viewer)
  28079. * > _min_: minification filter (far from the viewer)
  28080. * > _mip_: filter used between mip map levels
  28081. *@param samplingMode Define the new sampling mode of the texture
  28082. */
  28083. updateSamplingMode(samplingMode: number): void;
  28084. /**
  28085. * Scales the texture if is `canRescale()`
  28086. * @param ratio the resize factor we want to use to rescale
  28087. */
  28088. scale(ratio: number): void;
  28089. /**
  28090. * Get if the texture can rescale.
  28091. */
  28092. readonly canRescale: boolean;
  28093. /** @hidden */
  28094. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28095. /** @hidden */
  28096. _rebuild(): void;
  28097. /**
  28098. * Triggers the load sequence in delayed load mode.
  28099. */
  28100. delayLoad(): void;
  28101. /**
  28102. * Clones the texture.
  28103. * @returns the cloned texture
  28104. */
  28105. clone(): Nullable<BaseTexture>;
  28106. /**
  28107. * Get the texture underlying type (INT, FLOAT...)
  28108. */
  28109. readonly textureType: number;
  28110. /**
  28111. * Get the texture underlying format (RGB, RGBA...)
  28112. */
  28113. readonly textureFormat: number;
  28114. /**
  28115. * Indicates that textures need to be re-calculated for all materials
  28116. */
  28117. protected _markAllSubMeshesAsTexturesDirty(): void;
  28118. /**
  28119. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28120. * This will returns an RGBA array buffer containing either in values (0-255) or
  28121. * float values (0-1) depending of the underlying buffer type.
  28122. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28123. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28124. * @param buffer defines a user defined buffer to fill with data (can be null)
  28125. * @returns The Array buffer containing the pixels data.
  28126. */
  28127. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28128. /**
  28129. * Release and destroy the underlying lower level texture aka internalTexture.
  28130. */
  28131. releaseInternalTexture(): void;
  28132. /** @hidden */
  28133. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28134. /** @hidden */
  28135. readonly _lodTextureMid: Nullable<BaseTexture>;
  28136. /** @hidden */
  28137. readonly _lodTextureLow: Nullable<BaseTexture>;
  28138. /**
  28139. * Dispose the texture and release its associated resources.
  28140. */
  28141. dispose(): void;
  28142. /**
  28143. * Serialize the texture into a JSON representation that can be parsed later on.
  28144. * @returns the JSON representation of the texture
  28145. */
  28146. serialize(): any;
  28147. /**
  28148. * Helper function to be called back once a list of texture contains only ready textures.
  28149. * @param textures Define the list of textures to wait for
  28150. * @param callback Define the callback triggered once the entire list will be ready
  28151. */
  28152. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28153. }
  28154. }
  28155. declare module BABYLON {
  28156. /**
  28157. * Options to be used when creating an effect.
  28158. */
  28159. export interface IEffectCreationOptions {
  28160. /**
  28161. * Atrributes that will be used in the shader.
  28162. */
  28163. attributes: string[];
  28164. /**
  28165. * Uniform varible names that will be set in the shader.
  28166. */
  28167. uniformsNames: string[];
  28168. /**
  28169. * Uniform buffer varible names that will be set in the shader.
  28170. */
  28171. uniformBuffersNames: string[];
  28172. /**
  28173. * Sampler texture variable names that will be set in the shader.
  28174. */
  28175. samplers: string[];
  28176. /**
  28177. * Define statements that will be set in the shader.
  28178. */
  28179. defines: any;
  28180. /**
  28181. * Possible fallbacks for this effect to improve performance when needed.
  28182. */
  28183. fallbacks: Nullable<IEffectFallbacks>;
  28184. /**
  28185. * Callback that will be called when the shader is compiled.
  28186. */
  28187. onCompiled: Nullable<(effect: Effect) => void>;
  28188. /**
  28189. * Callback that will be called if an error occurs during shader compilation.
  28190. */
  28191. onError: Nullable<(effect: Effect, errors: string) => void>;
  28192. /**
  28193. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28194. */
  28195. indexParameters?: any;
  28196. /**
  28197. * Max number of lights that can be used in the shader.
  28198. */
  28199. maxSimultaneousLights?: number;
  28200. /**
  28201. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28202. */
  28203. transformFeedbackVaryings?: Nullable<string[]>;
  28204. }
  28205. /**
  28206. * Effect containing vertex and fragment shader that can be executed on an object.
  28207. */
  28208. export class Effect implements IDisposable {
  28209. /**
  28210. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28211. */
  28212. static ShadersRepository: string;
  28213. /**
  28214. * Name of the effect.
  28215. */
  28216. name: any;
  28217. /**
  28218. * String container all the define statements that should be set on the shader.
  28219. */
  28220. defines: string;
  28221. /**
  28222. * Callback that will be called when the shader is compiled.
  28223. */
  28224. onCompiled: Nullable<(effect: Effect) => void>;
  28225. /**
  28226. * Callback that will be called if an error occurs during shader compilation.
  28227. */
  28228. onError: Nullable<(effect: Effect, errors: string) => void>;
  28229. /**
  28230. * Callback that will be called when effect is bound.
  28231. */
  28232. onBind: Nullable<(effect: Effect) => void>;
  28233. /**
  28234. * Unique ID of the effect.
  28235. */
  28236. uniqueId: number;
  28237. /**
  28238. * Observable that will be called when the shader is compiled.
  28239. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28240. */
  28241. onCompileObservable: Observable<Effect>;
  28242. /**
  28243. * Observable that will be called if an error occurs during shader compilation.
  28244. */
  28245. onErrorObservable: Observable<Effect>;
  28246. /** @hidden */
  28247. _onBindObservable: Nullable<Observable<Effect>>;
  28248. /**
  28249. * Observable that will be called when effect is bound.
  28250. */
  28251. readonly onBindObservable: Observable<Effect>;
  28252. /** @hidden */
  28253. _bonesComputationForcedToCPU: boolean;
  28254. private static _uniqueIdSeed;
  28255. private _engine;
  28256. private _uniformBuffersNames;
  28257. private _uniformsNames;
  28258. private _samplerList;
  28259. private _samplers;
  28260. private _isReady;
  28261. private _compilationError;
  28262. private _allFallbacksProcessed;
  28263. private _attributesNames;
  28264. private _attributes;
  28265. private _uniforms;
  28266. /**
  28267. * Key for the effect.
  28268. * @hidden
  28269. */
  28270. _key: string;
  28271. private _indexParameters;
  28272. private _fallbacks;
  28273. private _vertexSourceCode;
  28274. private _fragmentSourceCode;
  28275. private _vertexSourceCodeOverride;
  28276. private _fragmentSourceCodeOverride;
  28277. private _transformFeedbackVaryings;
  28278. /**
  28279. * Compiled shader to webGL program.
  28280. * @hidden
  28281. */
  28282. _pipelineContext: Nullable<IPipelineContext>;
  28283. private _valueCache;
  28284. private static _baseCache;
  28285. /**
  28286. * Instantiates an effect.
  28287. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28288. * @param baseName Name of the effect.
  28289. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28290. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28291. * @param samplers List of sampler variables that will be passed to the shader.
  28292. * @param engine Engine to be used to render the effect
  28293. * @param defines Define statements to be added to the shader.
  28294. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28295. * @param onCompiled Callback that will be called when the shader is compiled.
  28296. * @param onError Callback that will be called if an error occurs during shader compilation.
  28297. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28298. */
  28299. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28300. private _useFinalCode;
  28301. /**
  28302. * Unique key for this effect
  28303. */
  28304. readonly key: string;
  28305. /**
  28306. * If the effect has been compiled and prepared.
  28307. * @returns if the effect is compiled and prepared.
  28308. */
  28309. isReady(): boolean;
  28310. private _isReadyInternal;
  28311. /**
  28312. * The engine the effect was initialized with.
  28313. * @returns the engine.
  28314. */
  28315. getEngine(): Engine;
  28316. /**
  28317. * The pipeline context for this effect
  28318. * @returns the associated pipeline context
  28319. */
  28320. getPipelineContext(): Nullable<IPipelineContext>;
  28321. /**
  28322. * The set of names of attribute variables for the shader.
  28323. * @returns An array of attribute names.
  28324. */
  28325. getAttributesNames(): string[];
  28326. /**
  28327. * Returns the attribute at the given index.
  28328. * @param index The index of the attribute.
  28329. * @returns The location of the attribute.
  28330. */
  28331. getAttributeLocation(index: number): number;
  28332. /**
  28333. * Returns the attribute based on the name of the variable.
  28334. * @param name of the attribute to look up.
  28335. * @returns the attribute location.
  28336. */
  28337. getAttributeLocationByName(name: string): number;
  28338. /**
  28339. * The number of attributes.
  28340. * @returns the numnber of attributes.
  28341. */
  28342. getAttributesCount(): number;
  28343. /**
  28344. * Gets the index of a uniform variable.
  28345. * @param uniformName of the uniform to look up.
  28346. * @returns the index.
  28347. */
  28348. getUniformIndex(uniformName: string): number;
  28349. /**
  28350. * Returns the attribute based on the name of the variable.
  28351. * @param uniformName of the uniform to look up.
  28352. * @returns the location of the uniform.
  28353. */
  28354. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28355. /**
  28356. * Returns an array of sampler variable names
  28357. * @returns The array of sampler variable neames.
  28358. */
  28359. getSamplers(): string[];
  28360. /**
  28361. * The error from the last compilation.
  28362. * @returns the error string.
  28363. */
  28364. getCompilationError(): string;
  28365. /**
  28366. * Gets a boolean indicating that all fallbacks were used during compilation
  28367. * @returns true if all fallbacks were used
  28368. */
  28369. allFallbacksProcessed(): boolean;
  28370. /**
  28371. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28372. * @param func The callback to be used.
  28373. */
  28374. executeWhenCompiled(func: (effect: Effect) => void): void;
  28375. private _checkIsReady;
  28376. private _loadShader;
  28377. /**
  28378. * Recompiles the webGL program
  28379. * @param vertexSourceCode The source code for the vertex shader.
  28380. * @param fragmentSourceCode The source code for the fragment shader.
  28381. * @param onCompiled Callback called when completed.
  28382. * @param onError Callback called on error.
  28383. * @hidden
  28384. */
  28385. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28386. /**
  28387. * Prepares the effect
  28388. * @hidden
  28389. */
  28390. _prepareEffect(): void;
  28391. private _processCompilationErrors;
  28392. /**
  28393. * Checks if the effect is supported. (Must be called after compilation)
  28394. */
  28395. readonly isSupported: boolean;
  28396. /**
  28397. * Binds a texture to the engine to be used as output of the shader.
  28398. * @param channel Name of the output variable.
  28399. * @param texture Texture to bind.
  28400. * @hidden
  28401. */
  28402. _bindTexture(channel: string, texture: InternalTexture): void;
  28403. /**
  28404. * Sets a texture on the engine to be used in the shader.
  28405. * @param channel Name of the sampler variable.
  28406. * @param texture Texture to set.
  28407. */
  28408. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28409. /**
  28410. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28411. * @param channel Name of the sampler variable.
  28412. * @param texture Texture to set.
  28413. */
  28414. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28415. /**
  28416. * Sets an array of textures on the engine to be used in the shader.
  28417. * @param channel Name of the variable.
  28418. * @param textures Textures to set.
  28419. */
  28420. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28421. /**
  28422. * 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)
  28423. * @param channel Name of the sampler variable.
  28424. * @param postProcess Post process to get the input texture from.
  28425. */
  28426. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28427. /**
  28428. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28429. * 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)
  28430. * @param channel Name of the sampler variable.
  28431. * @param postProcess Post process to get the output texture from.
  28432. */
  28433. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28434. /** @hidden */
  28435. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28436. /** @hidden */
  28437. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28438. /** @hidden */
  28439. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28440. /** @hidden */
  28441. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28442. /**
  28443. * Binds a buffer to a uniform.
  28444. * @param buffer Buffer to bind.
  28445. * @param name Name of the uniform variable to bind to.
  28446. */
  28447. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28448. /**
  28449. * Binds block to a uniform.
  28450. * @param blockName Name of the block to bind.
  28451. * @param index Index to bind.
  28452. */
  28453. bindUniformBlock(blockName: string, index: number): void;
  28454. /**
  28455. * Sets an interger value on a uniform variable.
  28456. * @param uniformName Name of the variable.
  28457. * @param value Value to be set.
  28458. * @returns this effect.
  28459. */
  28460. setInt(uniformName: string, value: number): Effect;
  28461. /**
  28462. * Sets an int array on a uniform variable.
  28463. * @param uniformName Name of the variable.
  28464. * @param array array to be set.
  28465. * @returns this effect.
  28466. */
  28467. setIntArray(uniformName: string, array: Int32Array): Effect;
  28468. /**
  28469. * 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)
  28470. * @param uniformName Name of the variable.
  28471. * @param array array to be set.
  28472. * @returns this effect.
  28473. */
  28474. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28475. /**
  28476. * 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)
  28477. * @param uniformName Name of the variable.
  28478. * @param array array to be set.
  28479. * @returns this effect.
  28480. */
  28481. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28482. /**
  28483. * 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)
  28484. * @param uniformName Name of the variable.
  28485. * @param array array to be set.
  28486. * @returns this effect.
  28487. */
  28488. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28489. /**
  28490. * Sets an float array on a uniform variable.
  28491. * @param uniformName Name of the variable.
  28492. * @param array array to be set.
  28493. * @returns this effect.
  28494. */
  28495. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28496. /**
  28497. * 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)
  28498. * @param uniformName Name of the variable.
  28499. * @param array array to be set.
  28500. * @returns this effect.
  28501. */
  28502. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28503. /**
  28504. * 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)
  28505. * @param uniformName Name of the variable.
  28506. * @param array array to be set.
  28507. * @returns this effect.
  28508. */
  28509. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28510. /**
  28511. * 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)
  28512. * @param uniformName Name of the variable.
  28513. * @param array array to be set.
  28514. * @returns this effect.
  28515. */
  28516. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28517. /**
  28518. * Sets an array on a uniform variable.
  28519. * @param uniformName Name of the variable.
  28520. * @param array array to be set.
  28521. * @returns this effect.
  28522. */
  28523. setArray(uniformName: string, array: number[]): Effect;
  28524. /**
  28525. * 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)
  28526. * @param uniformName Name of the variable.
  28527. * @param array array to be set.
  28528. * @returns this effect.
  28529. */
  28530. setArray2(uniformName: string, array: number[]): Effect;
  28531. /**
  28532. * 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)
  28533. * @param uniformName Name of the variable.
  28534. * @param array array to be set.
  28535. * @returns this effect.
  28536. */
  28537. setArray3(uniformName: string, array: number[]): Effect;
  28538. /**
  28539. * 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)
  28540. * @param uniformName Name of the variable.
  28541. * @param array array to be set.
  28542. * @returns this effect.
  28543. */
  28544. setArray4(uniformName: string, array: number[]): Effect;
  28545. /**
  28546. * Sets matrices on a uniform variable.
  28547. * @param uniformName Name of the variable.
  28548. * @param matrices matrices to be set.
  28549. * @returns this effect.
  28550. */
  28551. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28552. /**
  28553. * Sets matrix on a uniform variable.
  28554. * @param uniformName Name of the variable.
  28555. * @param matrix matrix to be set.
  28556. * @returns this effect.
  28557. */
  28558. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28559. /**
  28560. * 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)
  28561. * @param uniformName Name of the variable.
  28562. * @param matrix matrix to be set.
  28563. * @returns this effect.
  28564. */
  28565. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28566. /**
  28567. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28568. * @param uniformName Name of the variable.
  28569. * @param matrix matrix to be set.
  28570. * @returns this effect.
  28571. */
  28572. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28573. /**
  28574. * Sets a float on a uniform variable.
  28575. * @param uniformName Name of the variable.
  28576. * @param value value to be set.
  28577. * @returns this effect.
  28578. */
  28579. setFloat(uniformName: string, value: number): Effect;
  28580. /**
  28581. * Sets a boolean on a uniform variable.
  28582. * @param uniformName Name of the variable.
  28583. * @param bool value to be set.
  28584. * @returns this effect.
  28585. */
  28586. setBool(uniformName: string, bool: boolean): Effect;
  28587. /**
  28588. * Sets a Vector2 on a uniform variable.
  28589. * @param uniformName Name of the variable.
  28590. * @param vector2 vector2 to be set.
  28591. * @returns this effect.
  28592. */
  28593. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28594. /**
  28595. * Sets a float2 on a uniform variable.
  28596. * @param uniformName Name of the variable.
  28597. * @param x First float in float2.
  28598. * @param y Second float in float2.
  28599. * @returns this effect.
  28600. */
  28601. setFloat2(uniformName: string, x: number, y: number): Effect;
  28602. /**
  28603. * Sets a Vector3 on a uniform variable.
  28604. * @param uniformName Name of the variable.
  28605. * @param vector3 Value to be set.
  28606. * @returns this effect.
  28607. */
  28608. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28609. /**
  28610. * Sets a float3 on a uniform variable.
  28611. * @param uniformName Name of the variable.
  28612. * @param x First float in float3.
  28613. * @param y Second float in float3.
  28614. * @param z Third float in float3.
  28615. * @returns this effect.
  28616. */
  28617. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28618. /**
  28619. * Sets a Vector4 on a uniform variable.
  28620. * @param uniformName Name of the variable.
  28621. * @param vector4 Value to be set.
  28622. * @returns this effect.
  28623. */
  28624. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28625. /**
  28626. * Sets a float4 on a uniform variable.
  28627. * @param uniformName Name of the variable.
  28628. * @param x First float in float4.
  28629. * @param y Second float in float4.
  28630. * @param z Third float in float4.
  28631. * @param w Fourth float in float4.
  28632. * @returns this effect.
  28633. */
  28634. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28635. /**
  28636. * Sets a Color3 on a uniform variable.
  28637. * @param uniformName Name of the variable.
  28638. * @param color3 Value to be set.
  28639. * @returns this effect.
  28640. */
  28641. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28642. /**
  28643. * Sets a Color4 on a uniform variable.
  28644. * @param uniformName Name of the variable.
  28645. * @param color3 Value to be set.
  28646. * @param alpha Alpha value to be set.
  28647. * @returns this effect.
  28648. */
  28649. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28650. /**
  28651. * Sets a Color4 on a uniform variable
  28652. * @param uniformName defines the name of the variable
  28653. * @param color4 defines the value to be set
  28654. * @returns this effect.
  28655. */
  28656. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28657. /** Release all associated resources */
  28658. dispose(): void;
  28659. /**
  28660. * This function will add a new shader to the shader store
  28661. * @param name the name of the shader
  28662. * @param pixelShader optional pixel shader content
  28663. * @param vertexShader optional vertex shader content
  28664. */
  28665. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28666. /**
  28667. * Store of each shader (The can be looked up using effect.key)
  28668. */
  28669. static ShadersStore: {
  28670. [key: string]: string;
  28671. };
  28672. /**
  28673. * Store of each included file for a shader (The can be looked up using effect.key)
  28674. */
  28675. static IncludesShadersStore: {
  28676. [key: string]: string;
  28677. };
  28678. /**
  28679. * Resets the cache of effects.
  28680. */
  28681. static ResetCache(): void;
  28682. }
  28683. }
  28684. declare module BABYLON {
  28685. /**
  28686. * Interface used to describe the capabilities of the engine relatively to the current browser
  28687. */
  28688. export interface EngineCapabilities {
  28689. /** Maximum textures units per fragment shader */
  28690. maxTexturesImageUnits: number;
  28691. /** Maximum texture units per vertex shader */
  28692. maxVertexTextureImageUnits: number;
  28693. /** Maximum textures units in the entire pipeline */
  28694. maxCombinedTexturesImageUnits: number;
  28695. /** Maximum texture size */
  28696. maxTextureSize: number;
  28697. /** Maximum cube texture size */
  28698. maxCubemapTextureSize: number;
  28699. /** Maximum render texture size */
  28700. maxRenderTextureSize: number;
  28701. /** Maximum number of vertex attributes */
  28702. maxVertexAttribs: number;
  28703. /** Maximum number of varyings */
  28704. maxVaryingVectors: number;
  28705. /** Maximum number of uniforms per vertex shader */
  28706. maxVertexUniformVectors: number;
  28707. /** Maximum number of uniforms per fragment shader */
  28708. maxFragmentUniformVectors: number;
  28709. /** Defines if standard derivates (dx/dy) are supported */
  28710. standardDerivatives: boolean;
  28711. /** Defines if s3tc texture compression is supported */
  28712. s3tc?: WEBGL_compressed_texture_s3tc;
  28713. /** Defines if pvrtc texture compression is supported */
  28714. pvrtc: any;
  28715. /** Defines if etc1 texture compression is supported */
  28716. etc1: any;
  28717. /** Defines if etc2 texture compression is supported */
  28718. etc2: any;
  28719. /** Defines if astc texture compression is supported */
  28720. astc: any;
  28721. /** Defines if float textures are supported */
  28722. textureFloat: boolean;
  28723. /** Defines if vertex array objects are supported */
  28724. vertexArrayObject: boolean;
  28725. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28726. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28727. /** Gets the maximum level of anisotropy supported */
  28728. maxAnisotropy: number;
  28729. /** Defines if instancing is supported */
  28730. instancedArrays: boolean;
  28731. /** Defines if 32 bits indices are supported */
  28732. uintIndices: boolean;
  28733. /** Defines if high precision shaders are supported */
  28734. highPrecisionShaderSupported: boolean;
  28735. /** Defines if depth reading in the fragment shader is supported */
  28736. fragmentDepthSupported: boolean;
  28737. /** Defines if float texture linear filtering is supported*/
  28738. textureFloatLinearFiltering: boolean;
  28739. /** Defines if rendering to float textures is supported */
  28740. textureFloatRender: boolean;
  28741. /** Defines if half float textures are supported*/
  28742. textureHalfFloat: boolean;
  28743. /** Defines if half float texture linear filtering is supported*/
  28744. textureHalfFloatLinearFiltering: boolean;
  28745. /** Defines if rendering to half float textures is supported */
  28746. textureHalfFloatRender: boolean;
  28747. /** Defines if textureLOD shader command is supported */
  28748. textureLOD: boolean;
  28749. /** Defines if draw buffers extension is supported */
  28750. drawBuffersExtension: boolean;
  28751. /** Defines if depth textures are supported */
  28752. depthTextureExtension: boolean;
  28753. /** Defines if float color buffer are supported */
  28754. colorBufferFloat: boolean;
  28755. /** Gets disjoint timer query extension (null if not supported) */
  28756. timerQuery?: EXT_disjoint_timer_query;
  28757. /** Defines if timestamp can be used with timer query */
  28758. canUseTimestampForTimerQuery: boolean;
  28759. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28760. multiview?: any;
  28761. /** Function used to let the system compiles shaders in background */
  28762. parallelShaderCompile?: {
  28763. COMPLETION_STATUS_KHR: number;
  28764. };
  28765. /** Max number of texture samples for MSAA */
  28766. maxMSAASamples: number;
  28767. /** Defines if the blend min max extension is supported */
  28768. blendMinMax: boolean;
  28769. }
  28770. }
  28771. declare module BABYLON {
  28772. /**
  28773. * @hidden
  28774. **/
  28775. export class DepthCullingState {
  28776. private _isDepthTestDirty;
  28777. private _isDepthMaskDirty;
  28778. private _isDepthFuncDirty;
  28779. private _isCullFaceDirty;
  28780. private _isCullDirty;
  28781. private _isZOffsetDirty;
  28782. private _isFrontFaceDirty;
  28783. private _depthTest;
  28784. private _depthMask;
  28785. private _depthFunc;
  28786. private _cull;
  28787. private _cullFace;
  28788. private _zOffset;
  28789. private _frontFace;
  28790. /**
  28791. * Initializes the state.
  28792. */
  28793. constructor();
  28794. readonly isDirty: boolean;
  28795. zOffset: number;
  28796. cullFace: Nullable<number>;
  28797. cull: Nullable<boolean>;
  28798. depthFunc: Nullable<number>;
  28799. depthMask: boolean;
  28800. depthTest: boolean;
  28801. frontFace: Nullable<number>;
  28802. reset(): void;
  28803. apply(gl: WebGLRenderingContext): void;
  28804. }
  28805. }
  28806. declare module BABYLON {
  28807. /**
  28808. * @hidden
  28809. **/
  28810. export class StencilState {
  28811. /** 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 */
  28812. static readonly ALWAYS: number;
  28813. /** Passed to stencilOperation to specify that stencil value must be kept */
  28814. static readonly KEEP: number;
  28815. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28816. static readonly REPLACE: number;
  28817. private _isStencilTestDirty;
  28818. private _isStencilMaskDirty;
  28819. private _isStencilFuncDirty;
  28820. private _isStencilOpDirty;
  28821. private _stencilTest;
  28822. private _stencilMask;
  28823. private _stencilFunc;
  28824. private _stencilFuncRef;
  28825. private _stencilFuncMask;
  28826. private _stencilOpStencilFail;
  28827. private _stencilOpDepthFail;
  28828. private _stencilOpStencilDepthPass;
  28829. readonly isDirty: boolean;
  28830. stencilFunc: number;
  28831. stencilFuncRef: number;
  28832. stencilFuncMask: number;
  28833. stencilOpStencilFail: number;
  28834. stencilOpDepthFail: number;
  28835. stencilOpStencilDepthPass: number;
  28836. stencilMask: number;
  28837. stencilTest: boolean;
  28838. constructor();
  28839. reset(): void;
  28840. apply(gl: WebGLRenderingContext): void;
  28841. }
  28842. }
  28843. declare module BABYLON {
  28844. /**
  28845. * @hidden
  28846. **/
  28847. export class AlphaState {
  28848. private _isAlphaBlendDirty;
  28849. private _isBlendFunctionParametersDirty;
  28850. private _isBlendEquationParametersDirty;
  28851. private _isBlendConstantsDirty;
  28852. private _alphaBlend;
  28853. private _blendFunctionParameters;
  28854. private _blendEquationParameters;
  28855. private _blendConstants;
  28856. /**
  28857. * Initializes the state.
  28858. */
  28859. constructor();
  28860. readonly isDirty: boolean;
  28861. alphaBlend: boolean;
  28862. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28863. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28864. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28865. reset(): void;
  28866. apply(gl: WebGLRenderingContext): void;
  28867. }
  28868. }
  28869. declare module BABYLON {
  28870. /** @hidden */
  28871. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28872. attributeProcessor(attribute: string): string;
  28873. varyingProcessor(varying: string, isFragment: boolean): string;
  28874. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28875. }
  28876. }
  28877. declare module BABYLON {
  28878. /**
  28879. * Interface for attribute information associated with buffer instanciation
  28880. */
  28881. export interface InstancingAttributeInfo {
  28882. /**
  28883. * Index/offset of the attribute in the vertex shader
  28884. */
  28885. index: number;
  28886. /**
  28887. * size of the attribute, 1, 2, 3 or 4
  28888. */
  28889. attributeSize: number;
  28890. /**
  28891. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28892. * default is FLOAT
  28893. */
  28894. attributeType: number;
  28895. /**
  28896. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28897. */
  28898. normalized: boolean;
  28899. /**
  28900. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28901. */
  28902. offset: number;
  28903. /**
  28904. * Name of the GLSL attribute, for debugging purpose only
  28905. */
  28906. attributeName: string;
  28907. }
  28908. }
  28909. declare module BABYLON {
  28910. interface ThinEngine {
  28911. /**
  28912. * Update a video texture
  28913. * @param texture defines the texture to update
  28914. * @param video defines the video element to use
  28915. * @param invertY defines if data must be stored with Y axis inverted
  28916. */
  28917. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28918. }
  28919. }
  28920. declare module BABYLON {
  28921. /**
  28922. * Settings for finer control over video usage
  28923. */
  28924. export interface VideoTextureSettings {
  28925. /**
  28926. * Applies `autoplay` to video, if specified
  28927. */
  28928. autoPlay?: boolean;
  28929. /**
  28930. * Applies `loop` to video, if specified
  28931. */
  28932. loop?: boolean;
  28933. /**
  28934. * Automatically updates internal texture from video at every frame in the render loop
  28935. */
  28936. autoUpdateTexture: boolean;
  28937. /**
  28938. * Image src displayed during the video loading or until the user interacts with the video.
  28939. */
  28940. poster?: string;
  28941. }
  28942. /**
  28943. * If you want to display a video in your scene, this is the special texture for that.
  28944. * This special texture works similar to other textures, with the exception of a few parameters.
  28945. * @see https://doc.babylonjs.com/how_to/video_texture
  28946. */
  28947. export class VideoTexture extends Texture {
  28948. /**
  28949. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28950. */
  28951. readonly autoUpdateTexture: boolean;
  28952. /**
  28953. * The video instance used by the texture internally
  28954. */
  28955. readonly video: HTMLVideoElement;
  28956. private _onUserActionRequestedObservable;
  28957. /**
  28958. * Event triggerd when a dom action is required by the user to play the video.
  28959. * This happens due to recent changes in browser policies preventing video to auto start.
  28960. */
  28961. readonly onUserActionRequestedObservable: Observable<Texture>;
  28962. private _generateMipMaps;
  28963. private _engine;
  28964. private _stillImageCaptured;
  28965. private _displayingPosterTexture;
  28966. private _settings;
  28967. private _createInternalTextureOnEvent;
  28968. private _frameId;
  28969. /**
  28970. * Creates a video texture.
  28971. * If you want to display a video in your scene, this is the special texture for that.
  28972. * This special texture works similar to other textures, with the exception of a few parameters.
  28973. * @see https://doc.babylonjs.com/how_to/video_texture
  28974. * @param name optional name, will detect from video source, if not defined
  28975. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28976. * @param scene is obviously the current scene.
  28977. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28978. * @param invertY is false by default but can be used to invert video on Y axis
  28979. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28980. * @param settings allows finer control over video usage
  28981. */
  28982. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28983. private _getName;
  28984. private _getVideo;
  28985. private _createInternalTexture;
  28986. private reset;
  28987. /**
  28988. * @hidden Internal method to initiate `update`.
  28989. */
  28990. _rebuild(): void;
  28991. /**
  28992. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28993. */
  28994. update(): void;
  28995. /**
  28996. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28997. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28998. */
  28999. updateTexture(isVisible: boolean): void;
  29000. protected _updateInternalTexture: () => void;
  29001. /**
  29002. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29003. * @param url New url.
  29004. */
  29005. updateURL(url: string): void;
  29006. /**
  29007. * Dispose the texture and release its associated resources.
  29008. */
  29009. dispose(): void;
  29010. /**
  29011. * Creates a video texture straight from a stream.
  29012. * @param scene Define the scene the texture should be created in
  29013. * @param stream Define the stream the texture should be created from
  29014. * @returns The created video texture as a promise
  29015. */
  29016. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29017. /**
  29018. * Creates a video texture straight from your WebCam video feed.
  29019. * @param scene Define the scene the texture should be created in
  29020. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29021. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29022. * @returns The created video texture as a promise
  29023. */
  29024. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29025. minWidth: number;
  29026. maxWidth: number;
  29027. minHeight: number;
  29028. maxHeight: number;
  29029. deviceId: string;
  29030. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29031. /**
  29032. * Creates a video texture straight from your WebCam video feed.
  29033. * @param scene Define the scene the texture should be created in
  29034. * @param onReady Define a callback to triggered once the texture will be ready
  29035. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29036. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29037. */
  29038. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29039. minWidth: number;
  29040. maxWidth: number;
  29041. minHeight: number;
  29042. maxHeight: number;
  29043. deviceId: string;
  29044. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29045. }
  29046. }
  29047. declare module BABYLON {
  29048. /**
  29049. * Defines the interface used by objects working like Scene
  29050. * @hidden
  29051. */
  29052. interface ISceneLike {
  29053. _addPendingData(data: any): void;
  29054. _removePendingData(data: any): void;
  29055. offlineProvider: IOfflineProvider;
  29056. }
  29057. /** Interface defining initialization parameters for Engine class */
  29058. export interface EngineOptions extends WebGLContextAttributes {
  29059. /**
  29060. * Defines if the engine should no exceed a specified device ratio
  29061. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29062. */
  29063. limitDeviceRatio?: number;
  29064. /**
  29065. * Defines if webvr should be enabled automatically
  29066. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29067. */
  29068. autoEnableWebVR?: boolean;
  29069. /**
  29070. * Defines if webgl2 should be turned off even if supported
  29071. * @see http://doc.babylonjs.com/features/webgl2
  29072. */
  29073. disableWebGL2Support?: boolean;
  29074. /**
  29075. * Defines if webaudio should be initialized as well
  29076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29077. */
  29078. audioEngine?: boolean;
  29079. /**
  29080. * Defines if animations should run using a deterministic lock step
  29081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29082. */
  29083. deterministicLockstep?: boolean;
  29084. /** Defines the maximum steps to use with deterministic lock step mode */
  29085. lockstepMaxSteps?: number;
  29086. /**
  29087. * Defines that engine should ignore context lost events
  29088. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29089. */
  29090. doNotHandleContextLost?: boolean;
  29091. /**
  29092. * Defines that engine should ignore modifying touch action attribute and style
  29093. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29094. */
  29095. doNotHandleTouchAction?: boolean;
  29096. /**
  29097. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29098. */
  29099. useHighPrecisionFloats?: boolean;
  29100. }
  29101. /**
  29102. * The base engine class (root of all engines)
  29103. */
  29104. export class ThinEngine {
  29105. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29106. static ExceptionList: ({
  29107. key: string;
  29108. capture: string;
  29109. captureConstraint: number;
  29110. targets: string[];
  29111. } | {
  29112. key: string;
  29113. capture: null;
  29114. captureConstraint: null;
  29115. targets: string[];
  29116. })[];
  29117. /** @hidden */
  29118. static _TextureLoaders: IInternalTextureLoader[];
  29119. /**
  29120. * Returns the current npm package of the sdk
  29121. */
  29122. static readonly NpmPackage: string;
  29123. /**
  29124. * Returns the current version of the framework
  29125. */
  29126. static readonly Version: string;
  29127. /**
  29128. * Returns a string describing the current engine
  29129. */
  29130. readonly description: string;
  29131. /**
  29132. * Gets or sets the epsilon value used by collision engine
  29133. */
  29134. static CollisionsEpsilon: number;
  29135. /**
  29136. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29137. */
  29138. static ShadersRepository: string;
  29139. /** @hidden */
  29140. _shaderProcessor: IShaderProcessor;
  29141. /**
  29142. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29143. */
  29144. forcePOTTextures: boolean;
  29145. /**
  29146. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29147. */
  29148. isFullscreen: boolean;
  29149. /**
  29150. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29151. */
  29152. cullBackFaces: boolean;
  29153. /**
  29154. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29155. */
  29156. renderEvenInBackground: boolean;
  29157. /**
  29158. * Gets or sets a boolean indicating that cache can be kept between frames
  29159. */
  29160. preventCacheWipeBetweenFrames: boolean;
  29161. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29162. validateShaderPrograms: boolean;
  29163. /**
  29164. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29165. */
  29166. disableUniformBuffers: boolean;
  29167. /** @hidden */
  29168. _uniformBuffers: UniformBuffer[];
  29169. /**
  29170. * Gets a boolean indicating that the engine supports uniform buffers
  29171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29172. */
  29173. readonly supportsUniformBuffers: boolean;
  29174. /** @hidden */
  29175. _gl: WebGLRenderingContext;
  29176. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29177. protected _windowIsBackground: boolean;
  29178. protected _webGLVersion: number;
  29179. protected _creationOptions: EngineOptions;
  29180. protected _highPrecisionShadersAllowed: boolean;
  29181. /** @hidden */
  29182. readonly _shouldUseHighPrecisionShader: boolean;
  29183. /**
  29184. * Gets a boolean indicating that only power of 2 textures are supported
  29185. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29186. */
  29187. readonly needPOTTextures: boolean;
  29188. /** @hidden */
  29189. _badOS: boolean;
  29190. /** @hidden */
  29191. _badDesktopOS: boolean;
  29192. private _hardwareScalingLevel;
  29193. /** @hidden */
  29194. _caps: EngineCapabilities;
  29195. private _isStencilEnable;
  29196. protected _colorWrite: boolean;
  29197. private _glVersion;
  29198. private _glRenderer;
  29199. private _glVendor;
  29200. /** @hidden */
  29201. _videoTextureSupported: boolean;
  29202. protected _renderingQueueLaunched: boolean;
  29203. protected _activeRenderLoops: (() => void)[];
  29204. /**
  29205. * Observable signaled when a context lost event is raised
  29206. */
  29207. onContextLostObservable: Observable<ThinEngine>;
  29208. /**
  29209. * Observable signaled when a context restored event is raised
  29210. */
  29211. onContextRestoredObservable: Observable<ThinEngine>;
  29212. private _onContextLost;
  29213. private _onContextRestored;
  29214. protected _contextWasLost: boolean;
  29215. /** @hidden */
  29216. _doNotHandleContextLost: boolean;
  29217. /**
  29218. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29220. */
  29221. doNotHandleContextLost: boolean;
  29222. /**
  29223. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29224. */
  29225. disableVertexArrayObjects: boolean;
  29226. /** @hidden */
  29227. protected _depthCullingState: DepthCullingState;
  29228. /** @hidden */
  29229. protected _stencilState: StencilState;
  29230. /** @hidden */
  29231. protected _alphaState: AlphaState;
  29232. /** @hidden */
  29233. _internalTexturesCache: InternalTexture[];
  29234. /** @hidden */
  29235. protected _activeChannel: number;
  29236. private _currentTextureChannel;
  29237. /** @hidden */
  29238. protected _boundTexturesCache: {
  29239. [key: string]: Nullable<InternalTexture>;
  29240. };
  29241. /** @hidden */
  29242. protected _currentEffect: Nullable<Effect>;
  29243. /** @hidden */
  29244. protected _currentProgram: Nullable<WebGLProgram>;
  29245. private _compiledEffects;
  29246. private _vertexAttribArraysEnabled;
  29247. /** @hidden */
  29248. protected _cachedViewport: Nullable<IViewportLike>;
  29249. private _cachedVertexArrayObject;
  29250. /** @hidden */
  29251. protected _cachedVertexBuffers: any;
  29252. /** @hidden */
  29253. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29254. /** @hidden */
  29255. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29256. /** @hidden */
  29257. _currentRenderTarget: Nullable<InternalTexture>;
  29258. private _uintIndicesCurrentlySet;
  29259. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29260. /** @hidden */
  29261. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29262. private _currentBufferPointers;
  29263. private _currentInstanceLocations;
  29264. private _currentInstanceBuffers;
  29265. private _textureUnits;
  29266. /** @hidden */
  29267. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29268. /** @hidden */
  29269. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29270. /** @hidden */
  29271. _boundRenderFunction: any;
  29272. private _vaoRecordInProgress;
  29273. private _mustWipeVertexAttributes;
  29274. private _emptyTexture;
  29275. private _emptyCubeTexture;
  29276. private _emptyTexture3D;
  29277. /** @hidden */
  29278. _frameHandler: number;
  29279. private _nextFreeTextureSlots;
  29280. private _maxSimultaneousTextures;
  29281. private _activeRequests;
  29282. protected _texturesSupported: string[];
  29283. /** @hidden */
  29284. _textureFormatInUse: Nullable<string>;
  29285. protected readonly _supportsHardwareTextureRescaling: boolean;
  29286. /**
  29287. * Gets the list of texture formats supported
  29288. */
  29289. readonly texturesSupported: Array<string>;
  29290. /**
  29291. * Gets the list of texture formats in use
  29292. */
  29293. readonly textureFormatInUse: Nullable<string>;
  29294. /**
  29295. * Gets the current viewport
  29296. */
  29297. readonly currentViewport: Nullable<IViewportLike>;
  29298. /**
  29299. * Gets the default empty texture
  29300. */
  29301. readonly emptyTexture: InternalTexture;
  29302. /**
  29303. * Gets the default empty 3D texture
  29304. */
  29305. readonly emptyTexture3D: InternalTexture;
  29306. /**
  29307. * Gets the default empty cube texture
  29308. */
  29309. readonly emptyCubeTexture: InternalTexture;
  29310. /**
  29311. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29312. */
  29313. readonly premultipliedAlpha: boolean;
  29314. /**
  29315. * Observable event triggered before each texture is initialized
  29316. */
  29317. onBeforeTextureInitObservable: Observable<Texture>;
  29318. /**
  29319. * Creates a new engine
  29320. * @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
  29321. * @param antialias defines enable antialiasing (default: false)
  29322. * @param options defines further options to be sent to the getContext() function
  29323. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29324. */
  29325. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29326. private _rebuildInternalTextures;
  29327. private _rebuildEffects;
  29328. /**
  29329. * Gets a boolean indicating if all created effects are ready
  29330. * @returns true if all effects are ready
  29331. */
  29332. areAllEffectsReady(): boolean;
  29333. protected _rebuildBuffers(): void;
  29334. private _initGLContext;
  29335. /**
  29336. * Gets version of the current webGL context
  29337. */
  29338. readonly webGLVersion: number;
  29339. /**
  29340. * Gets a string idenfifying the name of the class
  29341. * @returns "Engine" string
  29342. */
  29343. getClassName(): string;
  29344. /**
  29345. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29346. */
  29347. readonly isStencilEnable: boolean;
  29348. /** @hidden */
  29349. _prepareWorkingCanvas(): void;
  29350. /**
  29351. * Reset the texture cache to empty state
  29352. */
  29353. resetTextureCache(): void;
  29354. /**
  29355. * Gets an object containing information about the current webGL context
  29356. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29357. */
  29358. getGlInfo(): {
  29359. vendor: string;
  29360. renderer: string;
  29361. version: string;
  29362. };
  29363. /**
  29364. * Defines the hardware scaling level.
  29365. * By default the hardware scaling level is computed from the window device ratio.
  29366. * 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.
  29367. * @param level defines the level to use
  29368. */
  29369. setHardwareScalingLevel(level: number): void;
  29370. /**
  29371. * Gets the current hardware scaling level.
  29372. * By default the hardware scaling level is computed from the window device ratio.
  29373. * 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.
  29374. * @returns a number indicating the current hardware scaling level
  29375. */
  29376. getHardwareScalingLevel(): number;
  29377. /**
  29378. * Gets the list of loaded textures
  29379. * @returns an array containing all loaded textures
  29380. */
  29381. getLoadedTexturesCache(): InternalTexture[];
  29382. /**
  29383. * Gets the object containing all engine capabilities
  29384. * @returns the EngineCapabilities object
  29385. */
  29386. getCaps(): EngineCapabilities;
  29387. /**
  29388. * stop executing a render loop function and remove it from the execution array
  29389. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29390. */
  29391. stopRenderLoop(renderFunction?: () => void): void;
  29392. /** @hidden */
  29393. _renderLoop(): void;
  29394. /**
  29395. * Gets the HTML canvas attached with the current webGL context
  29396. * @returns a HTML canvas
  29397. */
  29398. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29399. /**
  29400. * Gets host window
  29401. * @returns the host window object
  29402. */
  29403. getHostWindow(): Nullable<Window>;
  29404. /**
  29405. * Gets the current render width
  29406. * @param useScreen defines if screen size must be used (or the current render target if any)
  29407. * @returns a number defining the current render width
  29408. */
  29409. getRenderWidth(useScreen?: boolean): number;
  29410. /**
  29411. * Gets the current render height
  29412. * @param useScreen defines if screen size must be used (or the current render target if any)
  29413. * @returns a number defining the current render height
  29414. */
  29415. getRenderHeight(useScreen?: boolean): number;
  29416. /**
  29417. * Can be used to override the current requestAnimationFrame requester.
  29418. * @hidden
  29419. */
  29420. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29421. /**
  29422. * Register and execute a render loop. The engine can have more than one render function
  29423. * @param renderFunction defines the function to continuously execute
  29424. */
  29425. runRenderLoop(renderFunction: () => void): void;
  29426. /**
  29427. * Clear the current render buffer or the current render target (if any is set up)
  29428. * @param color defines the color to use
  29429. * @param backBuffer defines if the back buffer must be cleared
  29430. * @param depth defines if the depth buffer must be cleared
  29431. * @param stencil defines if the stencil buffer must be cleared
  29432. */
  29433. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29434. private _viewportCached;
  29435. /** @hidden */
  29436. _viewport(x: number, y: number, width: number, height: number): void;
  29437. /**
  29438. * Set the WebGL's viewport
  29439. * @param viewport defines the viewport element to be used
  29440. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29441. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29442. */
  29443. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29444. /**
  29445. * Begin a new frame
  29446. */
  29447. beginFrame(): void;
  29448. /**
  29449. * Enf the current frame
  29450. */
  29451. endFrame(): void;
  29452. /**
  29453. * Resize the view according to the canvas' size
  29454. */
  29455. resize(): void;
  29456. /**
  29457. * Force a specific size of the canvas
  29458. * @param width defines the new canvas' width
  29459. * @param height defines the new canvas' height
  29460. */
  29461. setSize(width: number, height: number): void;
  29462. /**
  29463. * Binds the frame buffer to the specified texture.
  29464. * @param texture The texture to render to or null for the default canvas
  29465. * @param faceIndex The face of the texture to render to in case of cube texture
  29466. * @param requiredWidth The width of the target to render to
  29467. * @param requiredHeight The height of the target to render to
  29468. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29469. * @param depthStencilTexture The depth stencil texture to use to render
  29470. * @param lodLevel defines le lod level to bind to the frame buffer
  29471. */
  29472. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29473. /** @hidden */
  29474. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29475. /**
  29476. * Unbind the current render target texture from the webGL context
  29477. * @param texture defines the render target texture to unbind
  29478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29480. */
  29481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29482. /**
  29483. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29484. */
  29485. flushFramebuffer(): void;
  29486. /**
  29487. * Unbind the current render target and bind the default framebuffer
  29488. */
  29489. restoreDefaultFramebuffer(): void;
  29490. /** @hidden */
  29491. protected _resetVertexBufferBinding(): void;
  29492. /**
  29493. * Creates a vertex buffer
  29494. * @param data the data for the vertex buffer
  29495. * @returns the new WebGL static buffer
  29496. */
  29497. createVertexBuffer(data: DataArray): DataBuffer;
  29498. private _createVertexBuffer;
  29499. /**
  29500. * Creates a dynamic vertex buffer
  29501. * @param data the data for the dynamic vertex buffer
  29502. * @returns the new WebGL dynamic buffer
  29503. */
  29504. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29505. protected _resetIndexBufferBinding(): void;
  29506. /**
  29507. * Creates a new index buffer
  29508. * @param indices defines the content of the index buffer
  29509. * @param updatable defines if the index buffer must be updatable
  29510. * @returns a new webGL buffer
  29511. */
  29512. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29513. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29514. /**
  29515. * Bind a webGL buffer to the webGL context
  29516. * @param buffer defines the buffer to bind
  29517. */
  29518. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29519. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29520. private bindBuffer;
  29521. /**
  29522. * update the bound buffer with the given data
  29523. * @param data defines the data to update
  29524. */
  29525. updateArrayBuffer(data: Float32Array): void;
  29526. private _vertexAttribPointer;
  29527. private _bindIndexBufferWithCache;
  29528. private _bindVertexBuffersAttributes;
  29529. /**
  29530. * Records a vertex array object
  29531. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29532. * @param vertexBuffers defines the list of vertex buffers to store
  29533. * @param indexBuffer defines the index buffer to store
  29534. * @param effect defines the effect to store
  29535. * @returns the new vertex array object
  29536. */
  29537. recordVertexArrayObject(vertexBuffers: {
  29538. [key: string]: VertexBuffer;
  29539. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29540. /**
  29541. * Bind a specific vertex array object
  29542. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29543. * @param vertexArrayObject defines the vertex array object to bind
  29544. * @param indexBuffer defines the index buffer to bind
  29545. */
  29546. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29547. /**
  29548. * Bind webGl buffers directly to the webGL context
  29549. * @param vertexBuffer defines the vertex buffer to bind
  29550. * @param indexBuffer defines the index buffer to bind
  29551. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29552. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29553. * @param effect defines the effect associated with the vertex buffer
  29554. */
  29555. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29556. private _unbindVertexArrayObject;
  29557. /**
  29558. * Bind a list of vertex buffers to the webGL context
  29559. * @param vertexBuffers defines the list of vertex buffers to bind
  29560. * @param indexBuffer defines the index buffer to bind
  29561. * @param effect defines the effect associated with the vertex buffers
  29562. */
  29563. bindBuffers(vertexBuffers: {
  29564. [key: string]: Nullable<VertexBuffer>;
  29565. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29566. /**
  29567. * Unbind all instance attributes
  29568. */
  29569. unbindInstanceAttributes(): void;
  29570. /**
  29571. * Release and free the memory of a vertex array object
  29572. * @param vao defines the vertex array object to delete
  29573. */
  29574. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29575. /** @hidden */
  29576. _releaseBuffer(buffer: DataBuffer): boolean;
  29577. protected _deleteBuffer(buffer: DataBuffer): void;
  29578. /**
  29579. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29580. * @param instancesBuffer defines the webGL buffer to update and bind
  29581. * @param data defines the data to store in the buffer
  29582. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29583. */
  29584. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29585. /**
  29586. * Apply all cached states (depth, culling, stencil and alpha)
  29587. */
  29588. applyStates(): void;
  29589. /**
  29590. * Send a draw order
  29591. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29592. * @param indexStart defines the starting index
  29593. * @param indexCount defines the number of index to draw
  29594. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29595. */
  29596. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29597. /**
  29598. * Draw a list of points
  29599. * @param verticesStart defines the index of first vertex to draw
  29600. * @param verticesCount defines the count of vertices to draw
  29601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29602. */
  29603. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29604. /**
  29605. * Draw a list of unindexed primitives
  29606. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29607. * @param verticesStart defines the index of first vertex to draw
  29608. * @param verticesCount defines the count of vertices to draw
  29609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29610. */
  29611. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29612. /**
  29613. * Draw a list of indexed primitives
  29614. * @param fillMode defines the primitive to use
  29615. * @param indexStart defines the starting index
  29616. * @param indexCount defines the number of index to draw
  29617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29618. */
  29619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29620. /**
  29621. * Draw a list of unindexed primitives
  29622. * @param fillMode defines the primitive to use
  29623. * @param verticesStart defines the index of first vertex to draw
  29624. * @param verticesCount defines the count of vertices to draw
  29625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29626. */
  29627. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29628. private _drawMode;
  29629. /** @hidden */
  29630. protected _reportDrawCall(): void;
  29631. /** @hidden */
  29632. _releaseEffect(effect: Effect): void;
  29633. /** @hidden */
  29634. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29635. /**
  29636. * Create a new effect (used to store vertex/fragment shaders)
  29637. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29638. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29639. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29640. * @param samplers defines an array of string used to represent textures
  29641. * @param defines defines the string containing the defines to use to compile the shaders
  29642. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29643. * @param onCompiled defines a function to call when the effect creation is successful
  29644. * @param onError defines a function to call when the effect creation has failed
  29645. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29646. * @returns the new Effect
  29647. */
  29648. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29649. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29650. private _compileShader;
  29651. private _compileRawShader;
  29652. /**
  29653. * Directly creates a webGL program
  29654. * @param pipelineContext defines the pipeline context to attach to
  29655. * @param vertexCode defines the vertex shader code to use
  29656. * @param fragmentCode defines the fragment shader code to use
  29657. * @param context defines the webGL context to use (if not set, the current one will be used)
  29658. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29659. * @returns the new webGL program
  29660. */
  29661. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29662. /**
  29663. * Creates a webGL program
  29664. * @param pipelineContext defines the pipeline context to attach to
  29665. * @param vertexCode defines the vertex shader code to use
  29666. * @param fragmentCode defines the fragment shader code to use
  29667. * @param defines defines the string containing the defines to use to compile the shaders
  29668. * @param context defines the webGL context to use (if not set, the current one will be used)
  29669. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29670. * @returns the new webGL program
  29671. */
  29672. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29673. /**
  29674. * Creates a new pipeline context
  29675. * @returns the new pipeline
  29676. */
  29677. createPipelineContext(): IPipelineContext;
  29678. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29679. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29680. /** @hidden */
  29681. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29682. /** @hidden */
  29683. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29684. /** @hidden */
  29685. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29686. /**
  29687. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29688. * @param pipelineContext defines the pipeline context to use
  29689. * @param uniformsNames defines the list of uniform names
  29690. * @returns an array of webGL uniform locations
  29691. */
  29692. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29693. /**
  29694. * Gets the lsit of active attributes for a given webGL program
  29695. * @param pipelineContext defines the pipeline context to use
  29696. * @param attributesNames defines the list of attribute names to get
  29697. * @returns an array of indices indicating the offset of each attribute
  29698. */
  29699. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29700. /**
  29701. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29702. * @param effect defines the effect to activate
  29703. */
  29704. enableEffect(effect: Nullable<Effect>): void;
  29705. /**
  29706. * Set the value of an uniform to a number (int)
  29707. * @param uniform defines the webGL uniform location where to store the value
  29708. * @param value defines the int number to store
  29709. */
  29710. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29711. /**
  29712. * Set the value of an uniform to an array of int32
  29713. * @param uniform defines the webGL uniform location where to store the value
  29714. * @param array defines the array of int32 to store
  29715. */
  29716. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29717. /**
  29718. * Set the value of an uniform to an array of int32 (stored as vec2)
  29719. * @param uniform defines the webGL uniform location where to store the value
  29720. * @param array defines the array of int32 to store
  29721. */
  29722. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29723. /**
  29724. * Set the value of an uniform to an array of int32 (stored as vec3)
  29725. * @param uniform defines the webGL uniform location where to store the value
  29726. * @param array defines the array of int32 to store
  29727. */
  29728. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29729. /**
  29730. * Set the value of an uniform to an array of int32 (stored as vec4)
  29731. * @param uniform defines the webGL uniform location where to store the value
  29732. * @param array defines the array of int32 to store
  29733. */
  29734. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29735. /**
  29736. * Set the value of an uniform to an array of number
  29737. * @param uniform defines the webGL uniform location where to store the value
  29738. * @param array defines the array of number to store
  29739. */
  29740. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29741. /**
  29742. * Set the value of an uniform to an array of number (stored as vec2)
  29743. * @param uniform defines the webGL uniform location where to store the value
  29744. * @param array defines the array of number to store
  29745. */
  29746. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29747. /**
  29748. * Set the value of an uniform to an array of number (stored as vec3)
  29749. * @param uniform defines the webGL uniform location where to store the value
  29750. * @param array defines the array of number to store
  29751. */
  29752. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29753. /**
  29754. * Set the value of an uniform to an array of number (stored as vec4)
  29755. * @param uniform defines the webGL uniform location where to store the value
  29756. * @param array defines the array of number to store
  29757. */
  29758. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29759. /**
  29760. * Set the value of an uniform to an array of float32 (stored as matrices)
  29761. * @param uniform defines the webGL uniform location where to store the value
  29762. * @param matrices defines the array of float32 to store
  29763. */
  29764. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29765. /**
  29766. * Set the value of an uniform to a matrix (3x3)
  29767. * @param uniform defines the webGL uniform location where to store the value
  29768. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29769. */
  29770. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29771. /**
  29772. * Set the value of an uniform to a matrix (2x2)
  29773. * @param uniform defines the webGL uniform location where to store the value
  29774. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29775. */
  29776. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29777. /**
  29778. * Set the value of an uniform to a number (float)
  29779. * @param uniform defines the webGL uniform location where to store the value
  29780. * @param value defines the float number to store
  29781. */
  29782. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29783. /**
  29784. * Set the value of an uniform to a vec2
  29785. * @param uniform defines the webGL uniform location where to store the value
  29786. * @param x defines the 1st component of the value
  29787. * @param y defines the 2nd component of the value
  29788. */
  29789. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29790. /**
  29791. * Set the value of an uniform to a vec3
  29792. * @param uniform defines the webGL uniform location where to store the value
  29793. * @param x defines the 1st component of the value
  29794. * @param y defines the 2nd component of the value
  29795. * @param z defines the 3rd component of the value
  29796. */
  29797. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29798. /**
  29799. * Set the value of an uniform to a vec4
  29800. * @param uniform defines the webGL uniform location where to store the value
  29801. * @param x defines the 1st component of the value
  29802. * @param y defines the 2nd component of the value
  29803. * @param z defines the 3rd component of the value
  29804. * @param w defines the 4th component of the value
  29805. */
  29806. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29807. /**
  29808. * Gets the depth culling state manager
  29809. */
  29810. readonly depthCullingState: DepthCullingState;
  29811. /**
  29812. * Gets the alpha state manager
  29813. */
  29814. readonly alphaState: AlphaState;
  29815. /**
  29816. * Gets the stencil state manager
  29817. */
  29818. readonly stencilState: StencilState;
  29819. /**
  29820. * Clears the list of texture accessible through engine.
  29821. * This can help preventing texture load conflict due to name collision.
  29822. */
  29823. clearInternalTexturesCache(): void;
  29824. /**
  29825. * Force the entire cache to be cleared
  29826. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29827. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29828. */
  29829. wipeCaches(bruteForce?: boolean): void;
  29830. /** @hidden */
  29831. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29832. min: number;
  29833. mag: number;
  29834. };
  29835. /** @hidden */
  29836. _createTexture(): WebGLTexture;
  29837. /**
  29838. * Usually called from Texture.ts.
  29839. * Passed information to create a WebGLTexture
  29840. * @param urlArg defines a value which contains one of the following:
  29841. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29842. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29843. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29844. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29845. * @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)
  29846. * @param scene needed for loading to the correct scene
  29847. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29848. * @param onLoad optional callback to be called upon successful completion
  29849. * @param onError optional callback to be called upon failure
  29850. * @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
  29851. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29852. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29853. * @param forcedExtension defines the extension to use to pick the right loader
  29854. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29855. * @param mimeType defines an optional mime type
  29856. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29857. */
  29858. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29859. /**
  29860. * @hidden
  29861. */
  29862. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29863. /**
  29864. * Creates a raw texture
  29865. * @param data defines the data to store in the texture
  29866. * @param width defines the width of the texture
  29867. * @param height defines the height of the texture
  29868. * @param format defines the format of the data
  29869. * @param generateMipMaps defines if the engine should generate the mip levels
  29870. * @param invertY defines if data must be stored with Y axis inverted
  29871. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29872. * @param compression defines the compression used (null by default)
  29873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29874. * @returns the raw texture inside an InternalTexture
  29875. */
  29876. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29877. /**
  29878. * Creates a new raw cube texture
  29879. * @param data defines the array of data to use to create each face
  29880. * @param size defines the size of the textures
  29881. * @param format defines the format of the data
  29882. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29883. * @param generateMipMaps defines if the engine should generate the mip levels
  29884. * @param invertY defines if data must be stored with Y axis inverted
  29885. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29886. * @param compression defines the compression used (null by default)
  29887. * @returns the cube texture as an InternalTexture
  29888. */
  29889. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29890. /**
  29891. * Creates a new raw 3D texture
  29892. * @param data defines the data used to create the texture
  29893. * @param width defines the width of the texture
  29894. * @param height defines the height of the texture
  29895. * @param depth defines the depth of the texture
  29896. * @param format defines the format of the texture
  29897. * @param generateMipMaps defines if the engine must generate mip levels
  29898. * @param invertY defines if data must be stored with Y axis inverted
  29899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29900. * @param compression defines the compressed used (can be null)
  29901. * @param textureType defines the compressed used (can be null)
  29902. * @returns a new raw 3D texture (stored in an InternalTexture)
  29903. */
  29904. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29905. private _unpackFlipYCached;
  29906. /**
  29907. * In case you are sharing the context with other applications, it might
  29908. * be interested to not cache the unpack flip y state to ensure a consistent
  29909. * value would be set.
  29910. */
  29911. enableUnpackFlipYCached: boolean;
  29912. /** @hidden */
  29913. _unpackFlipY(value: boolean): void;
  29914. /** @hidden */
  29915. _getUnpackAlignement(): number;
  29916. /**
  29917. * Update the sampling mode of a given texture
  29918. * @param samplingMode defines the required sampling mode
  29919. * @param texture defines the texture to update
  29920. */
  29921. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29922. /** @hidden */
  29923. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29924. width: number;
  29925. height: number;
  29926. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29927. /** @hidden */
  29928. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29929. /** @hidden */
  29930. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29931. /** @hidden */
  29932. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29933. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29934. private _prepareWebGLTexture;
  29935. /** @hidden */
  29936. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29937. /** @hidden */
  29938. _releaseFramebufferObjects(texture: InternalTexture): void;
  29939. /** @hidden */
  29940. _releaseTexture(texture: InternalTexture): void;
  29941. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29942. protected _setProgram(program: WebGLProgram): void;
  29943. protected _boundUniforms: {
  29944. [key: number]: WebGLUniformLocation;
  29945. };
  29946. /**
  29947. * Binds an effect to the webGL context
  29948. * @param effect defines the effect to bind
  29949. */
  29950. bindSamplers(effect: Effect): void;
  29951. private _activateCurrentTexture;
  29952. /** @hidden */
  29953. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29954. /** @hidden */
  29955. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29956. /**
  29957. * Unbind all textures from the webGL context
  29958. */
  29959. unbindAllTextures(): void;
  29960. /**
  29961. * Sets a texture to the according uniform.
  29962. * @param channel The texture channel
  29963. * @param uniform The uniform to set
  29964. * @param texture The texture to apply
  29965. */
  29966. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29967. private _bindSamplerUniformToChannel;
  29968. private _getTextureWrapMode;
  29969. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29970. /**
  29971. * Sets an array of texture to the webGL context
  29972. * @param channel defines the channel where the texture array must be set
  29973. * @param uniform defines the associated uniform location
  29974. * @param textures defines the array of textures to bind
  29975. */
  29976. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29977. /** @hidden */
  29978. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29979. private _setTextureParameterFloat;
  29980. private _setTextureParameterInteger;
  29981. /**
  29982. * Unbind all vertex attributes from the webGL context
  29983. */
  29984. unbindAllAttributes(): void;
  29985. /**
  29986. * 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
  29987. */
  29988. releaseEffects(): void;
  29989. /**
  29990. * Dispose and release all associated resources
  29991. */
  29992. dispose(): void;
  29993. /**
  29994. * Attach a new callback raised when context lost event is fired
  29995. * @param callback defines the callback to call
  29996. */
  29997. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29998. /**
  29999. * Attach a new callback raised when context restored event is fired
  30000. * @param callback defines the callback to call
  30001. */
  30002. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30003. /**
  30004. * Get the current error code of the webGL context
  30005. * @returns the error code
  30006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30007. */
  30008. getError(): number;
  30009. private _canRenderToFloatFramebuffer;
  30010. private _canRenderToHalfFloatFramebuffer;
  30011. private _canRenderToFramebuffer;
  30012. /** @hidden */
  30013. _getWebGLTextureType(type: number): number;
  30014. /** @hidden */
  30015. _getInternalFormat(format: number): number;
  30016. /** @hidden */
  30017. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30018. /** @hidden */
  30019. _getRGBAMultiSampleBufferFormat(type: number): number;
  30020. /** @hidden */
  30021. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30022. /**
  30023. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30024. * @returns true if the engine can be created
  30025. * @ignorenaming
  30026. */
  30027. static isSupported(): boolean;
  30028. /**
  30029. * Find the next highest power of two.
  30030. * @param x Number to start search from.
  30031. * @return Next highest power of two.
  30032. */
  30033. static CeilingPOT(x: number): number;
  30034. /**
  30035. * Find the next lowest power of two.
  30036. * @param x Number to start search from.
  30037. * @return Next lowest power of two.
  30038. */
  30039. static FloorPOT(x: number): number;
  30040. /**
  30041. * Find the nearest power of two.
  30042. * @param x Number to start search from.
  30043. * @return Next nearest power of two.
  30044. */
  30045. static NearestPOT(x: number): number;
  30046. /**
  30047. * Get the closest exponent of two
  30048. * @param value defines the value to approximate
  30049. * @param max defines the maximum value to return
  30050. * @param mode defines how to define the closest value
  30051. * @returns closest exponent of two of the given value
  30052. */
  30053. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30054. /**
  30055. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30056. * @param func - the function to be called
  30057. * @param requester - the object that will request the next frame. Falls back to window.
  30058. * @returns frame number
  30059. */
  30060. static QueueNewFrame(func: () => void, requester?: any): number;
  30061. }
  30062. }
  30063. declare module BABYLON {
  30064. /**
  30065. * Class representing spherical harmonics coefficients to the 3rd degree
  30066. */
  30067. export class SphericalHarmonics {
  30068. /**
  30069. * Defines whether or not the harmonics have been prescaled for rendering.
  30070. */
  30071. preScaled: boolean;
  30072. /**
  30073. * The l0,0 coefficients of the spherical harmonics
  30074. */
  30075. l00: Vector3;
  30076. /**
  30077. * The l1,-1 coefficients of the spherical harmonics
  30078. */
  30079. l1_1: Vector3;
  30080. /**
  30081. * The l1,0 coefficients of the spherical harmonics
  30082. */
  30083. l10: Vector3;
  30084. /**
  30085. * The l1,1 coefficients of the spherical harmonics
  30086. */
  30087. l11: Vector3;
  30088. /**
  30089. * The l2,-2 coefficients of the spherical harmonics
  30090. */
  30091. l2_2: Vector3;
  30092. /**
  30093. * The l2,-1 coefficients of the spherical harmonics
  30094. */
  30095. l2_1: Vector3;
  30096. /**
  30097. * The l2,0 coefficients of the spherical harmonics
  30098. */
  30099. l20: Vector3;
  30100. /**
  30101. * The l2,1 coefficients of the spherical harmonics
  30102. */
  30103. l21: Vector3;
  30104. /**
  30105. * The l2,2 coefficients of the spherical harmonics
  30106. */
  30107. l22: Vector3;
  30108. /**
  30109. * Adds a light to the spherical harmonics
  30110. * @param direction the direction of the light
  30111. * @param color the color of the light
  30112. * @param deltaSolidAngle the delta solid angle of the light
  30113. */
  30114. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30115. /**
  30116. * Scales the spherical harmonics by the given amount
  30117. * @param scale the amount to scale
  30118. */
  30119. scaleInPlace(scale: number): void;
  30120. /**
  30121. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30122. *
  30123. * ```
  30124. * E_lm = A_l * L_lm
  30125. * ```
  30126. *
  30127. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30128. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30129. * the scaling factors are given in equation 9.
  30130. */
  30131. convertIncidentRadianceToIrradiance(): void;
  30132. /**
  30133. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30134. *
  30135. * ```
  30136. * L = (1/pi) * E * rho
  30137. * ```
  30138. *
  30139. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30140. */
  30141. convertIrradianceToLambertianRadiance(): void;
  30142. /**
  30143. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30144. * required operations at run time.
  30145. *
  30146. * This is simply done by scaling back the SH with Ylm constants parameter.
  30147. * The trigonometric part being applied by the shader at run time.
  30148. */
  30149. preScaleForRendering(): void;
  30150. /**
  30151. * Constructs a spherical harmonics from an array.
  30152. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30153. * @returns the spherical harmonics
  30154. */
  30155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30156. /**
  30157. * Gets the spherical harmonics from polynomial
  30158. * @param polynomial the spherical polynomial
  30159. * @returns the spherical harmonics
  30160. */
  30161. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30162. }
  30163. /**
  30164. * Class representing spherical polynomial coefficients to the 3rd degree
  30165. */
  30166. export class SphericalPolynomial {
  30167. private _harmonics;
  30168. /**
  30169. * The spherical harmonics used to create the polynomials.
  30170. */
  30171. readonly preScaledHarmonics: SphericalHarmonics;
  30172. /**
  30173. * The x coefficients of the spherical polynomial
  30174. */
  30175. x: Vector3;
  30176. /**
  30177. * The y coefficients of the spherical polynomial
  30178. */
  30179. y: Vector3;
  30180. /**
  30181. * The z coefficients of the spherical polynomial
  30182. */
  30183. z: Vector3;
  30184. /**
  30185. * The xx coefficients of the spherical polynomial
  30186. */
  30187. xx: Vector3;
  30188. /**
  30189. * The yy coefficients of the spherical polynomial
  30190. */
  30191. yy: Vector3;
  30192. /**
  30193. * The zz coefficients of the spherical polynomial
  30194. */
  30195. zz: Vector3;
  30196. /**
  30197. * The xy coefficients of the spherical polynomial
  30198. */
  30199. xy: Vector3;
  30200. /**
  30201. * The yz coefficients of the spherical polynomial
  30202. */
  30203. yz: Vector3;
  30204. /**
  30205. * The zx coefficients of the spherical polynomial
  30206. */
  30207. zx: Vector3;
  30208. /**
  30209. * Adds an ambient color to the spherical polynomial
  30210. * @param color the color to add
  30211. */
  30212. addAmbient(color: Color3): void;
  30213. /**
  30214. * Scales the spherical polynomial by the given amount
  30215. * @param scale the amount to scale
  30216. */
  30217. scaleInPlace(scale: number): void;
  30218. /**
  30219. * Gets the spherical polynomial from harmonics
  30220. * @param harmonics the spherical harmonics
  30221. * @returns the spherical polynomial
  30222. */
  30223. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30224. /**
  30225. * Constructs a spherical polynomial from an array.
  30226. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30227. * @returns the spherical polynomial
  30228. */
  30229. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30230. }
  30231. }
  30232. declare module BABYLON {
  30233. /**
  30234. * Defines the source of the internal texture
  30235. */
  30236. export enum InternalTextureSource {
  30237. /**
  30238. * The source of the texture data is unknown
  30239. */
  30240. Unknown = 0,
  30241. /**
  30242. * Texture data comes from an URL
  30243. */
  30244. Url = 1,
  30245. /**
  30246. * Texture data is only used for temporary storage
  30247. */
  30248. Temp = 2,
  30249. /**
  30250. * Texture data comes from raw data (ArrayBuffer)
  30251. */
  30252. Raw = 3,
  30253. /**
  30254. * Texture content is dynamic (video or dynamic texture)
  30255. */
  30256. Dynamic = 4,
  30257. /**
  30258. * Texture content is generated by rendering to it
  30259. */
  30260. RenderTarget = 5,
  30261. /**
  30262. * Texture content is part of a multi render target process
  30263. */
  30264. MultiRenderTarget = 6,
  30265. /**
  30266. * Texture data comes from a cube data file
  30267. */
  30268. Cube = 7,
  30269. /**
  30270. * Texture data comes from a raw cube data
  30271. */
  30272. CubeRaw = 8,
  30273. /**
  30274. * Texture data come from a prefiltered cube data file
  30275. */
  30276. CubePrefiltered = 9,
  30277. /**
  30278. * Texture content is raw 3D data
  30279. */
  30280. Raw3D = 10,
  30281. /**
  30282. * Texture content is a depth texture
  30283. */
  30284. Depth = 11,
  30285. /**
  30286. * Texture data comes from a raw cube data encoded with RGBD
  30287. */
  30288. CubeRawRGBD = 12
  30289. }
  30290. /**
  30291. * Class used to store data associated with WebGL texture data for the engine
  30292. * This class should not be used directly
  30293. */
  30294. export class InternalTexture {
  30295. /** @hidden */
  30296. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30297. /**
  30298. * Defines if the texture is ready
  30299. */
  30300. isReady: boolean;
  30301. /**
  30302. * Defines if the texture is a cube texture
  30303. */
  30304. isCube: boolean;
  30305. /**
  30306. * Defines if the texture contains 3D data
  30307. */
  30308. is3D: boolean;
  30309. /**
  30310. * Defines if the texture contains multiview data
  30311. */
  30312. isMultiview: boolean;
  30313. /**
  30314. * Gets the URL used to load this texture
  30315. */
  30316. url: string;
  30317. /**
  30318. * Gets the sampling mode of the texture
  30319. */
  30320. samplingMode: number;
  30321. /**
  30322. * Gets a boolean indicating if the texture needs mipmaps generation
  30323. */
  30324. generateMipMaps: boolean;
  30325. /**
  30326. * Gets the number of samples used by the texture (WebGL2+ only)
  30327. */
  30328. samples: number;
  30329. /**
  30330. * Gets the type of the texture (int, float...)
  30331. */
  30332. type: number;
  30333. /**
  30334. * Gets the format of the texture (RGB, RGBA...)
  30335. */
  30336. format: number;
  30337. /**
  30338. * Observable called when the texture is loaded
  30339. */
  30340. onLoadedObservable: Observable<InternalTexture>;
  30341. /**
  30342. * Gets the width of the texture
  30343. */
  30344. width: number;
  30345. /**
  30346. * Gets the height of the texture
  30347. */
  30348. height: number;
  30349. /**
  30350. * Gets the depth of the texture
  30351. */
  30352. depth: number;
  30353. /**
  30354. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30355. */
  30356. baseWidth: number;
  30357. /**
  30358. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30359. */
  30360. baseHeight: number;
  30361. /**
  30362. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30363. */
  30364. baseDepth: number;
  30365. /**
  30366. * Gets a boolean indicating if the texture is inverted on Y axis
  30367. */
  30368. invertY: boolean;
  30369. /** @hidden */
  30370. _invertVScale: boolean;
  30371. /** @hidden */
  30372. _associatedChannel: number;
  30373. /** @hidden */
  30374. _source: InternalTextureSource;
  30375. /** @hidden */
  30376. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30377. /** @hidden */
  30378. _bufferView: Nullable<ArrayBufferView>;
  30379. /** @hidden */
  30380. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30381. /** @hidden */
  30382. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30383. /** @hidden */
  30384. _size: number;
  30385. /** @hidden */
  30386. _extension: string;
  30387. /** @hidden */
  30388. _files: Nullable<string[]>;
  30389. /** @hidden */
  30390. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30391. /** @hidden */
  30392. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30393. /** @hidden */
  30394. _framebuffer: Nullable<WebGLFramebuffer>;
  30395. /** @hidden */
  30396. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30397. /** @hidden */
  30398. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30399. /** @hidden */
  30400. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30401. /** @hidden */
  30402. _attachments: Nullable<number[]>;
  30403. /** @hidden */
  30404. _cachedCoordinatesMode: Nullable<number>;
  30405. /** @hidden */
  30406. _cachedWrapU: Nullable<number>;
  30407. /** @hidden */
  30408. _cachedWrapV: Nullable<number>;
  30409. /** @hidden */
  30410. _cachedWrapR: Nullable<number>;
  30411. /** @hidden */
  30412. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30413. /** @hidden */
  30414. _isDisabled: boolean;
  30415. /** @hidden */
  30416. _compression: Nullable<string>;
  30417. /** @hidden */
  30418. _generateStencilBuffer: boolean;
  30419. /** @hidden */
  30420. _generateDepthBuffer: boolean;
  30421. /** @hidden */
  30422. _comparisonFunction: number;
  30423. /** @hidden */
  30424. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30425. /** @hidden */
  30426. _lodGenerationScale: number;
  30427. /** @hidden */
  30428. _lodGenerationOffset: number;
  30429. /** @hidden */
  30430. _colorTextureArray: Nullable<WebGLTexture>;
  30431. /** @hidden */
  30432. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30433. /** @hidden */
  30434. _lodTextureHigh: Nullable<BaseTexture>;
  30435. /** @hidden */
  30436. _lodTextureMid: Nullable<BaseTexture>;
  30437. /** @hidden */
  30438. _lodTextureLow: Nullable<BaseTexture>;
  30439. /** @hidden */
  30440. _isRGBD: boolean;
  30441. /** @hidden */
  30442. _linearSpecularLOD: boolean;
  30443. /** @hidden */
  30444. _irradianceTexture: Nullable<BaseTexture>;
  30445. /** @hidden */
  30446. _webGLTexture: Nullable<WebGLTexture>;
  30447. /** @hidden */
  30448. _references: number;
  30449. private _engine;
  30450. /**
  30451. * Gets the Engine the texture belongs to.
  30452. * @returns The babylon engine
  30453. */
  30454. getEngine(): ThinEngine;
  30455. /**
  30456. * Gets the data source type of the texture
  30457. */
  30458. readonly source: InternalTextureSource;
  30459. /**
  30460. * Creates a new InternalTexture
  30461. * @param engine defines the engine to use
  30462. * @param source defines the type of data that will be used
  30463. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30464. */
  30465. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30466. /**
  30467. * Increments the number of references (ie. the number of Texture that point to it)
  30468. */
  30469. incrementReferences(): void;
  30470. /**
  30471. * Change the size of the texture (not the size of the content)
  30472. * @param width defines the new width
  30473. * @param height defines the new height
  30474. * @param depth defines the new depth (1 by default)
  30475. */
  30476. updateSize(width: int, height: int, depth?: int): void;
  30477. /** @hidden */
  30478. _rebuild(): void;
  30479. /** @hidden */
  30480. _swapAndDie(target: InternalTexture): void;
  30481. /**
  30482. * Dispose the current allocated resources
  30483. */
  30484. dispose(): void;
  30485. }
  30486. }
  30487. declare module BABYLON {
  30488. /**
  30489. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30491. */
  30492. export class Analyser {
  30493. /**
  30494. * Gets or sets the smoothing
  30495. * @ignorenaming
  30496. */
  30497. SMOOTHING: number;
  30498. /**
  30499. * Gets or sets the FFT table size
  30500. * @ignorenaming
  30501. */
  30502. FFT_SIZE: number;
  30503. /**
  30504. * Gets or sets the bar graph amplitude
  30505. * @ignorenaming
  30506. */
  30507. BARGRAPHAMPLITUDE: number;
  30508. /**
  30509. * Gets or sets the position of the debug canvas
  30510. * @ignorenaming
  30511. */
  30512. DEBUGCANVASPOS: {
  30513. x: number;
  30514. y: number;
  30515. };
  30516. /**
  30517. * Gets or sets the debug canvas size
  30518. * @ignorenaming
  30519. */
  30520. DEBUGCANVASSIZE: {
  30521. width: number;
  30522. height: number;
  30523. };
  30524. private _byteFreqs;
  30525. private _byteTime;
  30526. private _floatFreqs;
  30527. private _webAudioAnalyser;
  30528. private _debugCanvas;
  30529. private _debugCanvasContext;
  30530. private _scene;
  30531. private _registerFunc;
  30532. private _audioEngine;
  30533. /**
  30534. * Creates a new analyser
  30535. * @param scene defines hosting scene
  30536. */
  30537. constructor(scene: Scene);
  30538. /**
  30539. * Get the number of data values you will have to play with for the visualization
  30540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30541. * @returns a number
  30542. */
  30543. getFrequencyBinCount(): number;
  30544. /**
  30545. * Gets the current frequency data as a byte array
  30546. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30547. * @returns a Uint8Array
  30548. */
  30549. getByteFrequencyData(): Uint8Array;
  30550. /**
  30551. * Gets the current waveform as a byte array
  30552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30553. * @returns a Uint8Array
  30554. */
  30555. getByteTimeDomainData(): Uint8Array;
  30556. /**
  30557. * Gets the current frequency data as a float array
  30558. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30559. * @returns a Float32Array
  30560. */
  30561. getFloatFrequencyData(): Float32Array;
  30562. /**
  30563. * Renders the debug canvas
  30564. */
  30565. drawDebugCanvas(): void;
  30566. /**
  30567. * Stops rendering the debug canvas and removes it
  30568. */
  30569. stopDebugCanvas(): void;
  30570. /**
  30571. * Connects two audio nodes
  30572. * @param inputAudioNode defines first node to connect
  30573. * @param outputAudioNode defines second node to connect
  30574. */
  30575. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30576. /**
  30577. * Releases all associated resources
  30578. */
  30579. dispose(): void;
  30580. }
  30581. }
  30582. declare module BABYLON {
  30583. /**
  30584. * This represents an audio engine and it is responsible
  30585. * to play, synchronize and analyse sounds throughout the application.
  30586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30587. */
  30588. export interface IAudioEngine extends IDisposable {
  30589. /**
  30590. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30591. */
  30592. readonly canUseWebAudio: boolean;
  30593. /**
  30594. * Gets the current AudioContext if available.
  30595. */
  30596. readonly audioContext: Nullable<AudioContext>;
  30597. /**
  30598. * The master gain node defines the global audio volume of your audio engine.
  30599. */
  30600. readonly masterGain: GainNode;
  30601. /**
  30602. * Gets whether or not mp3 are supported by your browser.
  30603. */
  30604. readonly isMP3supported: boolean;
  30605. /**
  30606. * Gets whether or not ogg are supported by your browser.
  30607. */
  30608. readonly isOGGsupported: boolean;
  30609. /**
  30610. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30611. * @ignoreNaming
  30612. */
  30613. WarnedWebAudioUnsupported: boolean;
  30614. /**
  30615. * Defines if the audio engine relies on a custom unlocked button.
  30616. * In this case, the embedded button will not be displayed.
  30617. */
  30618. useCustomUnlockedButton: boolean;
  30619. /**
  30620. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30621. */
  30622. readonly unlocked: boolean;
  30623. /**
  30624. * Event raised when audio has been unlocked on the browser.
  30625. */
  30626. onAudioUnlockedObservable: Observable<AudioEngine>;
  30627. /**
  30628. * Event raised when audio has been locked on the browser.
  30629. */
  30630. onAudioLockedObservable: Observable<AudioEngine>;
  30631. /**
  30632. * Flags the audio engine in Locked state.
  30633. * This happens due to new browser policies preventing audio to autoplay.
  30634. */
  30635. lock(): void;
  30636. /**
  30637. * Unlocks the audio engine once a user action has been done on the dom.
  30638. * This is helpful to resume play once browser policies have been satisfied.
  30639. */
  30640. unlock(): void;
  30641. }
  30642. /**
  30643. * This represents the default audio engine used in babylon.
  30644. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30646. */
  30647. export class AudioEngine implements IAudioEngine {
  30648. private _audioContext;
  30649. private _audioContextInitialized;
  30650. private _muteButton;
  30651. private _hostElement;
  30652. /**
  30653. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30654. */
  30655. canUseWebAudio: boolean;
  30656. /**
  30657. * The master gain node defines the global audio volume of your audio engine.
  30658. */
  30659. masterGain: GainNode;
  30660. /**
  30661. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30662. * @ignoreNaming
  30663. */
  30664. WarnedWebAudioUnsupported: boolean;
  30665. /**
  30666. * Gets whether or not mp3 are supported by your browser.
  30667. */
  30668. isMP3supported: boolean;
  30669. /**
  30670. * Gets whether or not ogg are supported by your browser.
  30671. */
  30672. isOGGsupported: boolean;
  30673. /**
  30674. * Gets whether audio has been unlocked on the device.
  30675. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30676. * a user interaction has happened.
  30677. */
  30678. unlocked: boolean;
  30679. /**
  30680. * Defines if the audio engine relies on a custom unlocked button.
  30681. * In this case, the embedded button will not be displayed.
  30682. */
  30683. useCustomUnlockedButton: boolean;
  30684. /**
  30685. * Event raised when audio has been unlocked on the browser.
  30686. */
  30687. onAudioUnlockedObservable: Observable<AudioEngine>;
  30688. /**
  30689. * Event raised when audio has been locked on the browser.
  30690. */
  30691. onAudioLockedObservable: Observable<AudioEngine>;
  30692. /**
  30693. * Gets the current AudioContext if available.
  30694. */
  30695. readonly audioContext: Nullable<AudioContext>;
  30696. private _connectedAnalyser;
  30697. /**
  30698. * Instantiates a new audio engine.
  30699. *
  30700. * There should be only one per page as some browsers restrict the number
  30701. * of audio contexts you can create.
  30702. * @param hostElement defines the host element where to display the mute icon if necessary
  30703. */
  30704. constructor(hostElement?: Nullable<HTMLElement>);
  30705. /**
  30706. * Flags the audio engine in Locked state.
  30707. * This happens due to new browser policies preventing audio to autoplay.
  30708. */
  30709. lock(): void;
  30710. /**
  30711. * Unlocks the audio engine once a user action has been done on the dom.
  30712. * This is helpful to resume play once browser policies have been satisfied.
  30713. */
  30714. unlock(): void;
  30715. private _resumeAudioContext;
  30716. private _initializeAudioContext;
  30717. private _tryToRun;
  30718. private _triggerRunningState;
  30719. private _triggerSuspendedState;
  30720. private _displayMuteButton;
  30721. private _moveButtonToTopLeft;
  30722. private _onResize;
  30723. private _hideMuteButton;
  30724. /**
  30725. * Destroy and release the resources associated with the audio ccontext.
  30726. */
  30727. dispose(): void;
  30728. /**
  30729. * Gets the global volume sets on the master gain.
  30730. * @returns the global volume if set or -1 otherwise
  30731. */
  30732. getGlobalVolume(): number;
  30733. /**
  30734. * Sets the global volume of your experience (sets on the master gain).
  30735. * @param newVolume Defines the new global volume of the application
  30736. */
  30737. setGlobalVolume(newVolume: number): void;
  30738. /**
  30739. * Connect the audio engine to an audio analyser allowing some amazing
  30740. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30742. * @param analyser The analyser to connect to the engine
  30743. */
  30744. connectToAnalyser(analyser: Analyser): void;
  30745. }
  30746. }
  30747. declare module BABYLON {
  30748. /**
  30749. * Interface used to present a loading screen while loading a scene
  30750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30751. */
  30752. export interface ILoadingScreen {
  30753. /**
  30754. * Function called to display the loading screen
  30755. */
  30756. displayLoadingUI: () => void;
  30757. /**
  30758. * Function called to hide the loading screen
  30759. */
  30760. hideLoadingUI: () => void;
  30761. /**
  30762. * Gets or sets the color to use for the background
  30763. */
  30764. loadingUIBackgroundColor: string;
  30765. /**
  30766. * Gets or sets the text to display while loading
  30767. */
  30768. loadingUIText: string;
  30769. }
  30770. /**
  30771. * Class used for the default loading screen
  30772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30773. */
  30774. export class DefaultLoadingScreen implements ILoadingScreen {
  30775. private _renderingCanvas;
  30776. private _loadingText;
  30777. private _loadingDivBackgroundColor;
  30778. private _loadingDiv;
  30779. private _loadingTextDiv;
  30780. /** Gets or sets the logo url to use for the default loading screen */
  30781. static DefaultLogoUrl: string;
  30782. /** Gets or sets the spinner url to use for the default loading screen */
  30783. static DefaultSpinnerUrl: string;
  30784. /**
  30785. * Creates a new default loading screen
  30786. * @param _renderingCanvas defines the canvas used to render the scene
  30787. * @param _loadingText defines the default text to display
  30788. * @param _loadingDivBackgroundColor defines the default background color
  30789. */
  30790. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30791. /**
  30792. * Function called to display the loading screen
  30793. */
  30794. displayLoadingUI(): void;
  30795. /**
  30796. * Function called to hide the loading screen
  30797. */
  30798. hideLoadingUI(): void;
  30799. /**
  30800. * Gets or sets the text to display while loading
  30801. */
  30802. loadingUIText: string;
  30803. /**
  30804. * Gets or sets the color to use for the background
  30805. */
  30806. loadingUIBackgroundColor: string;
  30807. private _resizeLoadingUI;
  30808. }
  30809. }
  30810. declare module BABYLON {
  30811. /**
  30812. * Interface for any object that can request an animation frame
  30813. */
  30814. export interface ICustomAnimationFrameRequester {
  30815. /**
  30816. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30817. */
  30818. renderFunction?: Function;
  30819. /**
  30820. * Called to request the next frame to render to
  30821. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30822. */
  30823. requestAnimationFrame: Function;
  30824. /**
  30825. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30826. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30827. */
  30828. requestID?: number;
  30829. }
  30830. }
  30831. declare module BABYLON {
  30832. /**
  30833. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30834. */
  30835. export class PerformanceMonitor {
  30836. private _enabled;
  30837. private _rollingFrameTime;
  30838. private _lastFrameTimeMs;
  30839. /**
  30840. * constructor
  30841. * @param frameSampleSize The number of samples required to saturate the sliding window
  30842. */
  30843. constructor(frameSampleSize?: number);
  30844. /**
  30845. * Samples current frame
  30846. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30847. */
  30848. sampleFrame(timeMs?: number): void;
  30849. /**
  30850. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30851. */
  30852. readonly averageFrameTime: number;
  30853. /**
  30854. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30855. */
  30856. readonly averageFrameTimeVariance: number;
  30857. /**
  30858. * Returns the frame time of the most recent frame
  30859. */
  30860. readonly instantaneousFrameTime: number;
  30861. /**
  30862. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30863. */
  30864. readonly averageFPS: number;
  30865. /**
  30866. * Returns the average framerate in frames per second using the most recent frame time
  30867. */
  30868. readonly instantaneousFPS: number;
  30869. /**
  30870. * Returns true if enough samples have been taken to completely fill the sliding window
  30871. */
  30872. readonly isSaturated: boolean;
  30873. /**
  30874. * Enables contributions to the sliding window sample set
  30875. */
  30876. enable(): void;
  30877. /**
  30878. * Disables contributions to the sliding window sample set
  30879. * Samples will not be interpolated over the disabled period
  30880. */
  30881. disable(): void;
  30882. /**
  30883. * Returns true if sampling is enabled
  30884. */
  30885. readonly isEnabled: boolean;
  30886. /**
  30887. * Resets performance monitor
  30888. */
  30889. reset(): void;
  30890. }
  30891. /**
  30892. * RollingAverage
  30893. *
  30894. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30895. */
  30896. export class RollingAverage {
  30897. /**
  30898. * Current average
  30899. */
  30900. average: number;
  30901. /**
  30902. * Current variance
  30903. */
  30904. variance: number;
  30905. protected _samples: Array<number>;
  30906. protected _sampleCount: number;
  30907. protected _pos: number;
  30908. protected _m2: number;
  30909. /**
  30910. * constructor
  30911. * @param length The number of samples required to saturate the sliding window
  30912. */
  30913. constructor(length: number);
  30914. /**
  30915. * Adds a sample to the sample set
  30916. * @param v The sample value
  30917. */
  30918. add(v: number): void;
  30919. /**
  30920. * Returns previously added values or null if outside of history or outside the sliding window domain
  30921. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30922. * @return Value previously recorded with add() or null if outside of range
  30923. */
  30924. history(i: number): number;
  30925. /**
  30926. * Returns true if enough samples have been taken to completely fill the sliding window
  30927. * @return true if sample-set saturated
  30928. */
  30929. isSaturated(): boolean;
  30930. /**
  30931. * Resets the rolling average (equivalent to 0 samples taken so far)
  30932. */
  30933. reset(): void;
  30934. /**
  30935. * Wraps a value around the sample range boundaries
  30936. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30937. * @return Wrapped position in sample range
  30938. */
  30939. protected _wrapPosition(i: number): number;
  30940. }
  30941. }
  30942. declare module BABYLON {
  30943. /**
  30944. * This class is used to track a performance counter which is number based.
  30945. * The user has access to many properties which give statistics of different nature.
  30946. *
  30947. * The implementer can track two kinds of Performance Counter: time and count.
  30948. * 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.
  30949. * 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.
  30950. */
  30951. export class PerfCounter {
  30952. /**
  30953. * Gets or sets a global boolean to turn on and off all the counters
  30954. */
  30955. static Enabled: boolean;
  30956. /**
  30957. * Returns the smallest value ever
  30958. */
  30959. readonly min: number;
  30960. /**
  30961. * Returns the biggest value ever
  30962. */
  30963. readonly max: number;
  30964. /**
  30965. * Returns the average value since the performance counter is running
  30966. */
  30967. readonly average: number;
  30968. /**
  30969. * Returns the average value of the last second the counter was monitored
  30970. */
  30971. readonly lastSecAverage: number;
  30972. /**
  30973. * Returns the current value
  30974. */
  30975. readonly current: number;
  30976. /**
  30977. * Gets the accumulated total
  30978. */
  30979. readonly total: number;
  30980. /**
  30981. * Gets the total value count
  30982. */
  30983. readonly count: number;
  30984. /**
  30985. * Creates a new counter
  30986. */
  30987. constructor();
  30988. /**
  30989. * Call this method to start monitoring a new frame.
  30990. * 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.
  30991. */
  30992. fetchNewFrame(): void;
  30993. /**
  30994. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30995. * @param newCount the count value to add to the monitored count
  30996. * @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.
  30997. */
  30998. addCount(newCount: number, fetchResult: boolean): void;
  30999. /**
  31000. * Start monitoring this performance counter
  31001. */
  31002. beginMonitoring(): void;
  31003. /**
  31004. * Compute the time lapsed since the previous beginMonitoring() call.
  31005. * @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
  31006. */
  31007. endMonitoring(newFrame?: boolean): void;
  31008. private _fetchResult;
  31009. private _startMonitoringTime;
  31010. private _min;
  31011. private _max;
  31012. private _average;
  31013. private _current;
  31014. private _totalValueCount;
  31015. private _totalAccumulated;
  31016. private _lastSecAverage;
  31017. private _lastSecAccumulated;
  31018. private _lastSecTime;
  31019. private _lastSecValueCount;
  31020. }
  31021. }
  31022. declare module BABYLON {
  31023. /**
  31024. * Defines the interface used by display changed events
  31025. */
  31026. export interface IDisplayChangedEventArgs {
  31027. /** Gets the vrDisplay object (if any) */
  31028. vrDisplay: Nullable<any>;
  31029. /** Gets a boolean indicating if webVR is supported */
  31030. vrSupported: boolean;
  31031. }
  31032. /**
  31033. * Defines the interface used by objects containing a viewport (like a camera)
  31034. */
  31035. interface IViewportOwnerLike {
  31036. /**
  31037. * Gets or sets the viewport
  31038. */
  31039. viewport: IViewportLike;
  31040. }
  31041. /**
  31042. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31043. */
  31044. export class Engine extends ThinEngine {
  31045. /** Defines that alpha blending is disabled */
  31046. static readonly ALPHA_DISABLE: number;
  31047. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31048. static readonly ALPHA_ADD: number;
  31049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31050. static readonly ALPHA_COMBINE: number;
  31051. /** Defines that alpha blending to DEST - SRC * DEST */
  31052. static readonly ALPHA_SUBTRACT: number;
  31053. /** Defines that alpha blending to SRC * DEST */
  31054. static readonly ALPHA_MULTIPLY: number;
  31055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31056. static readonly ALPHA_MAXIMIZED: number;
  31057. /** Defines that alpha blending to SRC + DEST */
  31058. static readonly ALPHA_ONEONE: number;
  31059. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31060. static readonly ALPHA_PREMULTIPLIED: number;
  31061. /**
  31062. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31063. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31064. */
  31065. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31066. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31067. static readonly ALPHA_INTERPOLATE: number;
  31068. /**
  31069. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31070. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31071. */
  31072. static readonly ALPHA_SCREENMODE: number;
  31073. /** Defines that the ressource is not delayed*/
  31074. static readonly DELAYLOADSTATE_NONE: number;
  31075. /** Defines that the ressource was successfully delay loaded */
  31076. static readonly DELAYLOADSTATE_LOADED: number;
  31077. /** Defines that the ressource is currently delay loading */
  31078. static readonly DELAYLOADSTATE_LOADING: number;
  31079. /** Defines that the ressource is delayed and has not started loading */
  31080. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31082. static readonly NEVER: number;
  31083. /** 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 */
  31084. static readonly ALWAYS: number;
  31085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31086. static readonly LESS: number;
  31087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31088. static readonly EQUAL: number;
  31089. /** 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 */
  31090. static readonly LEQUAL: number;
  31091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31092. static readonly GREATER: number;
  31093. /** 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 */
  31094. static readonly GEQUAL: number;
  31095. /** 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 */
  31096. static readonly NOTEQUAL: number;
  31097. /** Passed to stencilOperation to specify that stencil value must be kept */
  31098. static readonly KEEP: number;
  31099. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31100. static readonly REPLACE: number;
  31101. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31102. static readonly INCR: number;
  31103. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31104. static readonly DECR: number;
  31105. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31106. static readonly INVERT: number;
  31107. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31108. static readonly INCR_WRAP: number;
  31109. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31110. static readonly DECR_WRAP: number;
  31111. /** Texture is not repeating outside of 0..1 UVs */
  31112. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31113. /** Texture is repeating outside of 0..1 UVs */
  31114. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31115. /** Texture is repeating and mirrored */
  31116. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31117. /** ALPHA */
  31118. static readonly TEXTUREFORMAT_ALPHA: number;
  31119. /** LUMINANCE */
  31120. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31121. /** LUMINANCE_ALPHA */
  31122. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31123. /** RGB */
  31124. static readonly TEXTUREFORMAT_RGB: number;
  31125. /** RGBA */
  31126. static readonly TEXTUREFORMAT_RGBA: number;
  31127. /** RED */
  31128. static readonly TEXTUREFORMAT_RED: number;
  31129. /** RED (2nd reference) */
  31130. static readonly TEXTUREFORMAT_R: number;
  31131. /** RG */
  31132. static readonly TEXTUREFORMAT_RG: number;
  31133. /** RED_INTEGER */
  31134. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31135. /** RED_INTEGER (2nd reference) */
  31136. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31137. /** RG_INTEGER */
  31138. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31139. /** RGB_INTEGER */
  31140. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31141. /** RGBA_INTEGER */
  31142. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31143. /** UNSIGNED_BYTE */
  31144. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31145. /** UNSIGNED_BYTE (2nd reference) */
  31146. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31147. /** FLOAT */
  31148. static readonly TEXTURETYPE_FLOAT: number;
  31149. /** HALF_FLOAT */
  31150. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31151. /** BYTE */
  31152. static readonly TEXTURETYPE_BYTE: number;
  31153. /** SHORT */
  31154. static readonly TEXTURETYPE_SHORT: number;
  31155. /** UNSIGNED_SHORT */
  31156. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31157. /** INT */
  31158. static readonly TEXTURETYPE_INT: number;
  31159. /** UNSIGNED_INT */
  31160. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31161. /** UNSIGNED_SHORT_4_4_4_4 */
  31162. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31163. /** UNSIGNED_SHORT_5_5_5_1 */
  31164. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31165. /** UNSIGNED_SHORT_5_6_5 */
  31166. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31167. /** UNSIGNED_INT_2_10_10_10_REV */
  31168. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31169. /** UNSIGNED_INT_24_8 */
  31170. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31171. /** UNSIGNED_INT_10F_11F_11F_REV */
  31172. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31173. /** UNSIGNED_INT_5_9_9_9_REV */
  31174. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31175. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31176. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31177. /** nearest is mag = nearest and min = nearest and mip = linear */
  31178. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31179. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31180. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31181. /** Trilinear is mag = linear and min = linear and mip = linear */
  31182. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31183. /** nearest is mag = nearest and min = nearest and mip = linear */
  31184. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31186. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31187. /** Trilinear is mag = linear and min = linear and mip = linear */
  31188. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31189. /** mag = nearest and min = nearest and mip = nearest */
  31190. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31191. /** mag = nearest and min = linear and mip = nearest */
  31192. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31193. /** mag = nearest and min = linear and mip = linear */
  31194. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31195. /** mag = nearest and min = linear and mip = none */
  31196. static readonly TEXTURE_NEAREST_LINEAR: number;
  31197. /** mag = nearest and min = nearest and mip = none */
  31198. static readonly TEXTURE_NEAREST_NEAREST: number;
  31199. /** mag = linear and min = nearest and mip = nearest */
  31200. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31201. /** mag = linear and min = nearest and mip = linear */
  31202. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31203. /** mag = linear and min = linear and mip = none */
  31204. static readonly TEXTURE_LINEAR_LINEAR: number;
  31205. /** mag = linear and min = nearest and mip = none */
  31206. static readonly TEXTURE_LINEAR_NEAREST: number;
  31207. /** Explicit coordinates mode */
  31208. static readonly TEXTURE_EXPLICIT_MODE: number;
  31209. /** Spherical coordinates mode */
  31210. static readonly TEXTURE_SPHERICAL_MODE: number;
  31211. /** Planar coordinates mode */
  31212. static readonly TEXTURE_PLANAR_MODE: number;
  31213. /** Cubic coordinates mode */
  31214. static readonly TEXTURE_CUBIC_MODE: number;
  31215. /** Projection coordinates mode */
  31216. static readonly TEXTURE_PROJECTION_MODE: number;
  31217. /** Skybox coordinates mode */
  31218. static readonly TEXTURE_SKYBOX_MODE: number;
  31219. /** Inverse Cubic coordinates mode */
  31220. static readonly TEXTURE_INVCUBIC_MODE: number;
  31221. /** Equirectangular coordinates mode */
  31222. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31223. /** Equirectangular Fixed coordinates mode */
  31224. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31225. /** Equirectangular Fixed Mirrored coordinates mode */
  31226. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31227. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31228. static readonly SCALEMODE_FLOOR: number;
  31229. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31230. static readonly SCALEMODE_NEAREST: number;
  31231. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31232. static readonly SCALEMODE_CEILING: number;
  31233. /**
  31234. * Returns the current npm package of the sdk
  31235. */
  31236. static readonly NpmPackage: string;
  31237. /**
  31238. * Returns the current version of the framework
  31239. */
  31240. static readonly Version: string;
  31241. /** Gets the list of created engines */
  31242. static readonly Instances: Engine[];
  31243. /**
  31244. * Gets the latest created engine
  31245. */
  31246. static readonly LastCreatedEngine: Nullable<Engine>;
  31247. /**
  31248. * Gets the latest created scene
  31249. */
  31250. static readonly LastCreatedScene: Nullable<Scene>;
  31251. /**
  31252. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31253. * @param flag defines which part of the materials must be marked as dirty
  31254. * @param predicate defines a predicate used to filter which materials should be affected
  31255. */
  31256. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31257. /**
  31258. * Method called to create the default loading screen.
  31259. * This can be overriden in your own app.
  31260. * @param canvas The rendering canvas element
  31261. * @returns The loading screen
  31262. */
  31263. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31264. /**
  31265. * Method called to create the default rescale post process on each engine.
  31266. */
  31267. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31268. /**
  31269. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31270. **/
  31271. enableOfflineSupport: boolean;
  31272. /**
  31273. * 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)
  31274. **/
  31275. disableManifestCheck: boolean;
  31276. /**
  31277. * Gets the list of created scenes
  31278. */
  31279. scenes: Scene[];
  31280. /**
  31281. * Event raised when a new scene is created
  31282. */
  31283. onNewSceneAddedObservable: Observable<Scene>;
  31284. /**
  31285. * Gets the list of created postprocesses
  31286. */
  31287. postProcesses: PostProcess[];
  31288. /**
  31289. * Gets a boolean indicating if the pointer is currently locked
  31290. */
  31291. isPointerLock: boolean;
  31292. /**
  31293. * Observable event triggered each time the rendering canvas is resized
  31294. */
  31295. onResizeObservable: Observable<Engine>;
  31296. /**
  31297. * Observable event triggered each time the canvas loses focus
  31298. */
  31299. onCanvasBlurObservable: Observable<Engine>;
  31300. /**
  31301. * Observable event triggered each time the canvas gains focus
  31302. */
  31303. onCanvasFocusObservable: Observable<Engine>;
  31304. /**
  31305. * Observable event triggered each time the canvas receives pointerout event
  31306. */
  31307. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31308. /**
  31309. * Observable raised when the engine begins a new frame
  31310. */
  31311. onBeginFrameObservable: Observable<Engine>;
  31312. /**
  31313. * If set, will be used to request the next animation frame for the render loop
  31314. */
  31315. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31316. /**
  31317. * Observable raised when the engine ends the current frame
  31318. */
  31319. onEndFrameObservable: Observable<Engine>;
  31320. /**
  31321. * Observable raised when the engine is about to compile a shader
  31322. */
  31323. onBeforeShaderCompilationObservable: Observable<Engine>;
  31324. /**
  31325. * Observable raised when the engine has jsut compiled a shader
  31326. */
  31327. onAfterShaderCompilationObservable: Observable<Engine>;
  31328. /**
  31329. * Gets the audio engine
  31330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31331. * @ignorenaming
  31332. */
  31333. static audioEngine: IAudioEngine;
  31334. /**
  31335. * Default AudioEngine factory responsible of creating the Audio Engine.
  31336. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31337. */
  31338. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31339. /**
  31340. * Default offline support factory responsible of creating a tool used to store data locally.
  31341. * By default, this will create a Database object if the workload has been embedded.
  31342. */
  31343. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31344. private _loadingScreen;
  31345. private _pointerLockRequested;
  31346. private _dummyFramebuffer;
  31347. private _rescalePostProcess;
  31348. /** @hidden */
  31349. protected _alphaMode: number;
  31350. /** @hidden */
  31351. protected _alphaEquation: number;
  31352. private _deterministicLockstep;
  31353. private _lockstepMaxSteps;
  31354. protected readonly _supportsHardwareTextureRescaling: boolean;
  31355. private _fps;
  31356. private _deltaTime;
  31357. /** @hidden */
  31358. _drawCalls: PerfCounter;
  31359. /**
  31360. * Turn this value on if you want to pause FPS computation when in background
  31361. */
  31362. disablePerformanceMonitorInBackground: boolean;
  31363. private _performanceMonitor;
  31364. /**
  31365. * Gets the performance monitor attached to this engine
  31366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31367. */
  31368. readonly performanceMonitor: PerformanceMonitor;
  31369. private _onFocus;
  31370. private _onBlur;
  31371. private _onCanvasPointerOut;
  31372. private _onCanvasBlur;
  31373. private _onCanvasFocus;
  31374. private _onFullscreenChange;
  31375. private _onPointerLockChange;
  31376. /**
  31377. * Creates a new engine
  31378. * @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
  31379. * @param antialias defines enable antialiasing (default: false)
  31380. * @param options defines further options to be sent to the getContext() function
  31381. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31382. */
  31383. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31384. /**
  31385. * Gets current aspect ratio
  31386. * @param viewportOwner defines the camera to use to get the aspect ratio
  31387. * @param useScreen defines if screen size must be used (or the current render target if any)
  31388. * @returns a number defining the aspect ratio
  31389. */
  31390. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31391. /**
  31392. * Gets current screen aspect ratio
  31393. * @returns a number defining the aspect ratio
  31394. */
  31395. getScreenAspectRatio(): number;
  31396. /**
  31397. * Gets host document
  31398. * @returns the host document object
  31399. */
  31400. getHostDocument(): Document;
  31401. /**
  31402. * Gets the client rect of the HTML canvas attached with the current webGL context
  31403. * @returns a client rectanglee
  31404. */
  31405. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31406. /**
  31407. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31409. * @returns true if engine is in deterministic lock step mode
  31410. */
  31411. isDeterministicLockStep(): boolean;
  31412. /**
  31413. * Gets the max steps when engine is running in deterministic lock step
  31414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31415. * @returns the max steps
  31416. */
  31417. getLockstepMaxSteps(): number;
  31418. /**
  31419. * Force the mipmap generation for the given render target texture
  31420. * @param texture defines the render target texture to use
  31421. */
  31422. generateMipMapsForCubemap(texture: InternalTexture): void;
  31423. /** States */
  31424. /**
  31425. * Set various states to the webGL context
  31426. * @param culling defines backface culling state
  31427. * @param zOffset defines the value to apply to zOffset (0 by default)
  31428. * @param force defines if states must be applied even if cache is up to date
  31429. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31430. */
  31431. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31432. /**
  31433. * Set the z offset to apply to current rendering
  31434. * @param value defines the offset to apply
  31435. */
  31436. setZOffset(value: number): void;
  31437. /**
  31438. * Gets the current value of the zOffset
  31439. * @returns the current zOffset state
  31440. */
  31441. getZOffset(): number;
  31442. /**
  31443. * Enable or disable depth buffering
  31444. * @param enable defines the state to set
  31445. */
  31446. setDepthBuffer(enable: boolean): void;
  31447. /**
  31448. * Gets a boolean indicating if depth writing is enabled
  31449. * @returns the current depth writing state
  31450. */
  31451. getDepthWrite(): boolean;
  31452. /**
  31453. * Enable or disable depth writing
  31454. * @param enable defines the state to set
  31455. */
  31456. setDepthWrite(enable: boolean): void;
  31457. /**
  31458. * Enable or disable color writing
  31459. * @param enable defines the state to set
  31460. */
  31461. setColorWrite(enable: boolean): void;
  31462. /**
  31463. * Gets a boolean indicating if color writing is enabled
  31464. * @returns the current color writing state
  31465. */
  31466. getColorWrite(): boolean;
  31467. /**
  31468. * Sets alpha constants used by some alpha blending modes
  31469. * @param r defines the red component
  31470. * @param g defines the green component
  31471. * @param b defines the blue component
  31472. * @param a defines the alpha component
  31473. */
  31474. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31475. /**
  31476. * Sets the current alpha mode
  31477. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31478. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31480. */
  31481. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31482. /**
  31483. * Gets the current alpha mode
  31484. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31485. * @returns the current alpha mode
  31486. */
  31487. getAlphaMode(): number;
  31488. /**
  31489. * Sets the current alpha equation
  31490. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31491. */
  31492. setAlphaEquation(equation: number): void;
  31493. /**
  31494. * Gets the current alpha equation.
  31495. * @returns the current alpha equation
  31496. */
  31497. getAlphaEquation(): number;
  31498. /**
  31499. * Gets a boolean indicating if stencil buffer is enabled
  31500. * @returns the current stencil buffer state
  31501. */
  31502. getStencilBuffer(): boolean;
  31503. /**
  31504. * Enable or disable the stencil buffer
  31505. * @param enable defines if the stencil buffer must be enabled or disabled
  31506. */
  31507. setStencilBuffer(enable: boolean): void;
  31508. /**
  31509. * Gets the current stencil mask
  31510. * @returns a number defining the new stencil mask to use
  31511. */
  31512. getStencilMask(): number;
  31513. /**
  31514. * Sets the current stencil mask
  31515. * @param mask defines the new stencil mask to use
  31516. */
  31517. setStencilMask(mask: number): void;
  31518. /**
  31519. * Gets the current stencil function
  31520. * @returns a number defining the stencil function to use
  31521. */
  31522. getStencilFunction(): number;
  31523. /**
  31524. * Gets the current stencil reference value
  31525. * @returns a number defining the stencil reference value to use
  31526. */
  31527. getStencilFunctionReference(): number;
  31528. /**
  31529. * Gets the current stencil mask
  31530. * @returns a number defining the stencil mask to use
  31531. */
  31532. getStencilFunctionMask(): number;
  31533. /**
  31534. * Sets the current stencil function
  31535. * @param stencilFunc defines the new stencil function to use
  31536. */
  31537. setStencilFunction(stencilFunc: number): void;
  31538. /**
  31539. * Sets the current stencil reference
  31540. * @param reference defines the new stencil reference to use
  31541. */
  31542. setStencilFunctionReference(reference: number): void;
  31543. /**
  31544. * Sets the current stencil mask
  31545. * @param mask defines the new stencil mask to use
  31546. */
  31547. setStencilFunctionMask(mask: number): void;
  31548. /**
  31549. * Gets the current stencil operation when stencil fails
  31550. * @returns a number defining stencil operation to use when stencil fails
  31551. */
  31552. getStencilOperationFail(): number;
  31553. /**
  31554. * Gets the current stencil operation when depth fails
  31555. * @returns a number defining stencil operation to use when depth fails
  31556. */
  31557. getStencilOperationDepthFail(): number;
  31558. /**
  31559. * Gets the current stencil operation when stencil passes
  31560. * @returns a number defining stencil operation to use when stencil passes
  31561. */
  31562. getStencilOperationPass(): number;
  31563. /**
  31564. * Sets the stencil operation to use when stencil fails
  31565. * @param operation defines the stencil operation to use when stencil fails
  31566. */
  31567. setStencilOperationFail(operation: number): void;
  31568. /**
  31569. * Sets the stencil operation to use when depth fails
  31570. * @param operation defines the stencil operation to use when depth fails
  31571. */
  31572. setStencilOperationDepthFail(operation: number): void;
  31573. /**
  31574. * Sets the stencil operation to use when stencil passes
  31575. * @param operation defines the stencil operation to use when stencil passes
  31576. */
  31577. setStencilOperationPass(operation: number): void;
  31578. /**
  31579. * Sets a boolean indicating if the dithering state is enabled or disabled
  31580. * @param value defines the dithering state
  31581. */
  31582. setDitheringState(value: boolean): void;
  31583. /**
  31584. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31585. * @param value defines the rasterizer state
  31586. */
  31587. setRasterizerState(value: boolean): void;
  31588. /**
  31589. * Gets the current depth function
  31590. * @returns a number defining the depth function
  31591. */
  31592. getDepthFunction(): Nullable<number>;
  31593. /**
  31594. * Sets the current depth function
  31595. * @param depthFunc defines the function to use
  31596. */
  31597. setDepthFunction(depthFunc: number): void;
  31598. /**
  31599. * Sets the current depth function to GREATER
  31600. */
  31601. setDepthFunctionToGreater(): void;
  31602. /**
  31603. * Sets the current depth function to GEQUAL
  31604. */
  31605. setDepthFunctionToGreaterOrEqual(): void;
  31606. /**
  31607. * Sets the current depth function to LESS
  31608. */
  31609. setDepthFunctionToLess(): void;
  31610. /**
  31611. * Sets the current depth function to LEQUAL
  31612. */
  31613. setDepthFunctionToLessOrEqual(): void;
  31614. private _cachedStencilBuffer;
  31615. private _cachedStencilFunction;
  31616. private _cachedStencilMask;
  31617. private _cachedStencilOperationPass;
  31618. private _cachedStencilOperationFail;
  31619. private _cachedStencilOperationDepthFail;
  31620. private _cachedStencilReference;
  31621. /**
  31622. * Caches the the state of the stencil buffer
  31623. */
  31624. cacheStencilState(): void;
  31625. /**
  31626. * Restores the state of the stencil buffer
  31627. */
  31628. restoreStencilState(): void;
  31629. /**
  31630. * Directly set the WebGL Viewport
  31631. * @param x defines the x coordinate of the viewport (in screen space)
  31632. * @param y defines the y coordinate of the viewport (in screen space)
  31633. * @param width defines the width of the viewport (in screen space)
  31634. * @param height defines the height of the viewport (in screen space)
  31635. * @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
  31636. */
  31637. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31638. /**
  31639. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31640. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31641. * @param y defines the y-coordinate of the corner of the clear rectangle
  31642. * @param width defines the width of the clear rectangle
  31643. * @param height defines the height of the clear rectangle
  31644. * @param clearColor defines the clear color
  31645. */
  31646. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31647. /**
  31648. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31649. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31650. * @param y defines the y-coordinate of the corner of the clear rectangle
  31651. * @param width defines the width of the clear rectangle
  31652. * @param height defines the height of the clear rectangle
  31653. */
  31654. enableScissor(x: number, y: number, width: number, height: number): void;
  31655. /**
  31656. * Disable previously set scissor test rectangle
  31657. */
  31658. disableScissor(): void;
  31659. protected _reportDrawCall(): void;
  31660. /**
  31661. * Initializes a webVR display and starts listening to display change events
  31662. * The onVRDisplayChangedObservable will be notified upon these changes
  31663. * @returns The onVRDisplayChangedObservable
  31664. */
  31665. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31666. /** @hidden */
  31667. _prepareVRComponent(): void;
  31668. /** @hidden */
  31669. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31670. /** @hidden */
  31671. _submitVRFrame(): void;
  31672. /**
  31673. * Call this function to leave webVR mode
  31674. * Will do nothing if webVR is not supported or if there is no webVR device
  31675. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31676. */
  31677. disableVR(): void;
  31678. /**
  31679. * Gets a boolean indicating that the system is in VR mode and is presenting
  31680. * @returns true if VR mode is engaged
  31681. */
  31682. isVRPresenting(): boolean;
  31683. /** @hidden */
  31684. _requestVRFrame(): void;
  31685. /** @hidden */
  31686. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31687. /**
  31688. * Gets the source code of the vertex shader associated with a specific webGL program
  31689. * @param program defines the program to use
  31690. * @returns a string containing the source code of the vertex shader associated with the program
  31691. */
  31692. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31693. /**
  31694. * Gets the source code of the fragment shader associated with a specific webGL program
  31695. * @param program defines the program to use
  31696. * @returns a string containing the source code of the fragment shader associated with the program
  31697. */
  31698. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31699. /**
  31700. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31701. * @param x defines the x coordinate of the rectangle where pixels must be read
  31702. * @param y defines the y coordinate of the rectangle where pixels must be read
  31703. * @param width defines the width of the rectangle where pixels must be read
  31704. * @param height defines the height of the rectangle where pixels must be read
  31705. * @returns a Uint8Array containing RGBA colors
  31706. */
  31707. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31708. /**
  31709. * Sets a depth stencil texture from a render target to the according uniform.
  31710. * @param channel The texture channel
  31711. * @param uniform The uniform to set
  31712. * @param texture The render target texture containing the depth stencil texture to apply
  31713. */
  31714. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31715. /**
  31716. * Sets a texture to the webGL context from a postprocess
  31717. * @param channel defines the channel to use
  31718. * @param postProcess defines the source postprocess
  31719. */
  31720. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31721. /**
  31722. * Binds the output of the passed in post process to the texture channel specified
  31723. * @param channel The channel the texture should be bound to
  31724. * @param postProcess The post process which's output should be bound
  31725. */
  31726. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31727. /** @hidden */
  31728. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31729. protected _rebuildBuffers(): void;
  31730. /** @hidden */
  31731. _renderFrame(): void;
  31732. _renderLoop(): void;
  31733. /** @hidden */
  31734. _renderViews(): void;
  31735. /**
  31736. * Toggle full screen mode
  31737. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31738. */
  31739. switchFullscreen(requestPointerLock: boolean): void;
  31740. /**
  31741. * Enters full screen mode
  31742. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31743. */
  31744. enterFullscreen(requestPointerLock: boolean): void;
  31745. /**
  31746. * Exits full screen mode
  31747. */
  31748. exitFullscreen(): void;
  31749. /**
  31750. * Enters Pointerlock mode
  31751. */
  31752. enterPointerlock(): void;
  31753. /**
  31754. * Exits Pointerlock mode
  31755. */
  31756. exitPointerlock(): void;
  31757. /**
  31758. * Begin a new frame
  31759. */
  31760. beginFrame(): void;
  31761. /**
  31762. * Enf the current frame
  31763. */
  31764. endFrame(): void;
  31765. resize(): void;
  31766. /**
  31767. * Set the compressed texture format to use, based on the formats you have, and the formats
  31768. * supported by the hardware / browser.
  31769. *
  31770. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31771. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31772. * to API arguments needed to compressed textures. This puts the burden on the container
  31773. * generator to house the arcane code for determining these for current & future formats.
  31774. *
  31775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31777. *
  31778. * Note: The result of this call is not taken into account when a texture is base64.
  31779. *
  31780. * @param formatsAvailable defines the list of those format families you have created
  31781. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31782. *
  31783. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31784. * @returns The extension selected.
  31785. */
  31786. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31787. /**
  31788. * Force a specific size of the canvas
  31789. * @param width defines the new canvas' width
  31790. * @param height defines the new canvas' height
  31791. */
  31792. setSize(width: number, height: number): void;
  31793. /**
  31794. * Updates a dynamic vertex buffer.
  31795. * @param vertexBuffer the vertex buffer to update
  31796. * @param data the data used to update the vertex buffer
  31797. * @param byteOffset the byte offset of the data
  31798. * @param byteLength the byte length of the data
  31799. */
  31800. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31801. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31802. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31803. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31804. _releaseTexture(texture: InternalTexture): void;
  31805. /**
  31806. * @hidden
  31807. * Rescales a texture
  31808. * @param source input texutre
  31809. * @param destination destination texture
  31810. * @param scene scene to use to render the resize
  31811. * @param internalFormat format to use when resizing
  31812. * @param onComplete callback to be called when resize has completed
  31813. */
  31814. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31815. /**
  31816. * Gets the current framerate
  31817. * @returns a number representing the framerate
  31818. */
  31819. getFps(): number;
  31820. /**
  31821. * Gets the time spent between current and previous frame
  31822. * @returns a number representing the delta time in ms
  31823. */
  31824. getDeltaTime(): number;
  31825. private _measureFps;
  31826. /** @hidden */
  31827. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  31828. /**
  31829. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31830. * @param renderTarget The render target to set the frame buffer for
  31831. */
  31832. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31833. /**
  31834. * Update a dynamic index buffer
  31835. * @param indexBuffer defines the target index buffer
  31836. * @param indices defines the data to update
  31837. * @param offset defines the offset in the target index buffer where update should start
  31838. */
  31839. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31840. /**
  31841. * Updates the sample count of a render target texture
  31842. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31843. * @param texture defines the texture to update
  31844. * @param samples defines the sample count to set
  31845. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31846. */
  31847. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31848. /**
  31849. * Updates a depth texture Comparison Mode and Function.
  31850. * If the comparison Function is equal to 0, the mode will be set to none.
  31851. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31852. * @param texture The texture to set the comparison function for
  31853. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31854. */
  31855. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31856. /**
  31857. * Creates a webGL buffer to use with instanciation
  31858. * @param capacity defines the size of the buffer
  31859. * @returns the webGL buffer
  31860. */
  31861. createInstancesBuffer(capacity: number): DataBuffer;
  31862. /**
  31863. * Delete a webGL buffer used with instanciation
  31864. * @param buffer defines the webGL buffer to delete
  31865. */
  31866. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31867. /** @hidden */
  31868. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31869. dispose(): void;
  31870. private _disableTouchAction;
  31871. /**
  31872. * Display the loading screen
  31873. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31874. */
  31875. displayLoadingUI(): void;
  31876. /**
  31877. * Hide the loading screen
  31878. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31879. */
  31880. hideLoadingUI(): void;
  31881. /**
  31882. * Gets the current loading screen object
  31883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31884. */
  31885. /**
  31886. * Sets the current loading screen object
  31887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31888. */
  31889. loadingScreen: ILoadingScreen;
  31890. /**
  31891. * Sets the current loading screen text
  31892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31893. */
  31894. loadingUIText: string;
  31895. /**
  31896. * Sets the current loading screen background color
  31897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31898. */
  31899. loadingUIBackgroundColor: string;
  31900. /** Pointerlock and fullscreen */
  31901. /**
  31902. * Ask the browser to promote the current element to pointerlock mode
  31903. * @param element defines the DOM element to promote
  31904. */
  31905. static _RequestPointerlock(element: HTMLElement): void;
  31906. /**
  31907. * Asks the browser to exit pointerlock mode
  31908. */
  31909. static _ExitPointerlock(): void;
  31910. /**
  31911. * Ask the browser to promote the current element to fullscreen rendering mode
  31912. * @param element defines the DOM element to promote
  31913. */
  31914. static _RequestFullscreen(element: HTMLElement): void;
  31915. /**
  31916. * Asks the browser to exit fullscreen mode
  31917. */
  31918. static _ExitFullscreen(): void;
  31919. }
  31920. }
  31921. declare module BABYLON {
  31922. /**
  31923. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31924. * during the life time of the application.
  31925. */
  31926. export class EngineStore {
  31927. /** Gets the list of created engines */
  31928. static Instances: Engine[];
  31929. /** @hidden */
  31930. static _LastCreatedScene: Nullable<Scene>;
  31931. /**
  31932. * Gets the latest created engine
  31933. */
  31934. static readonly LastCreatedEngine: Nullable<Engine>;
  31935. /**
  31936. * Gets the latest created scene
  31937. */
  31938. static readonly LastCreatedScene: Nullable<Scene>;
  31939. /**
  31940. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31941. * @ignorenaming
  31942. */
  31943. static UseFallbackTexture: boolean;
  31944. /**
  31945. * Texture content used if a texture cannot loaded
  31946. * @ignorenaming
  31947. */
  31948. static FallbackTexture: string;
  31949. }
  31950. }
  31951. declare module BABYLON {
  31952. /**
  31953. * Helper class that provides a small promise polyfill
  31954. */
  31955. export class PromisePolyfill {
  31956. /**
  31957. * Static function used to check if the polyfill is required
  31958. * If this is the case then the function will inject the polyfill to window.Promise
  31959. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31960. */
  31961. static Apply(force?: boolean): void;
  31962. }
  31963. }
  31964. declare module BABYLON {
  31965. /**
  31966. * Interface for screenshot methods with describe argument called `size` as object with options
  31967. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31968. */
  31969. export interface IScreenshotSize {
  31970. /**
  31971. * number in pixels for canvas height
  31972. */
  31973. height?: number;
  31974. /**
  31975. * multiplier allowing render at a higher or lower resolution
  31976. * If value is defined then height and width will be ignored and taken from camera
  31977. */
  31978. precision?: number;
  31979. /**
  31980. * number in pixels for canvas width
  31981. */
  31982. width?: number;
  31983. }
  31984. }
  31985. declare module BABYLON {
  31986. interface IColor4Like {
  31987. r: float;
  31988. g: float;
  31989. b: float;
  31990. a: float;
  31991. }
  31992. /**
  31993. * Class containing a set of static utilities functions
  31994. */
  31995. export class Tools {
  31996. /**
  31997. * Gets or sets the base URL to use to load assets
  31998. */
  31999. static BaseUrl: string;
  32000. /**
  32001. * Enable/Disable Custom HTTP Request Headers globally.
  32002. * default = false
  32003. * @see CustomRequestHeaders
  32004. */
  32005. static UseCustomRequestHeaders: boolean;
  32006. /**
  32007. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32008. * i.e. when loading files, where the server/service expects an Authorization header
  32009. */
  32010. static CustomRequestHeaders: {
  32011. [key: string]: string;
  32012. };
  32013. /**
  32014. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32015. */
  32016. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32017. /**
  32018. * Default behaviour for cors in the application.
  32019. * It can be a string if the expected behavior is identical in the entire app.
  32020. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32021. */
  32022. static CorsBehavior: string | ((url: string | string[]) => string);
  32023. /**
  32024. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32025. * @ignorenaming
  32026. */
  32027. static UseFallbackTexture: boolean;
  32028. /**
  32029. * Use this object to register external classes like custom textures or material
  32030. * to allow the laoders to instantiate them
  32031. */
  32032. static RegisteredExternalClasses: {
  32033. [key: string]: Object;
  32034. };
  32035. /**
  32036. * Texture content used if a texture cannot loaded
  32037. * @ignorenaming
  32038. */
  32039. static fallbackTexture: string;
  32040. /**
  32041. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32042. * @param u defines the coordinate on X axis
  32043. * @param v defines the coordinate on Y axis
  32044. * @param width defines the width of the source data
  32045. * @param height defines the height of the source data
  32046. * @param pixels defines the source byte array
  32047. * @param color defines the output color
  32048. */
  32049. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32050. /**
  32051. * Interpolates between a and b via alpha
  32052. * @param a The lower value (returned when alpha = 0)
  32053. * @param b The upper value (returned when alpha = 1)
  32054. * @param alpha The interpolation-factor
  32055. * @return The mixed value
  32056. */
  32057. static Mix(a: number, b: number, alpha: number): number;
  32058. /**
  32059. * Tries to instantiate a new object from a given class name
  32060. * @param className defines the class name to instantiate
  32061. * @returns the new object or null if the system was not able to do the instantiation
  32062. */
  32063. static Instantiate(className: string): any;
  32064. /**
  32065. * Provides a slice function that will work even on IE
  32066. * @param data defines the array to slice
  32067. * @param start defines the start of the data (optional)
  32068. * @param end defines the end of the data (optional)
  32069. * @returns the new sliced array
  32070. */
  32071. static Slice<T>(data: T, start?: number, end?: number): T;
  32072. /**
  32073. * Polyfill for setImmediate
  32074. * @param action defines the action to execute after the current execution block
  32075. */
  32076. static SetImmediate(action: () => void): void;
  32077. /**
  32078. * Function indicating if a number is an exponent of 2
  32079. * @param value defines the value to test
  32080. * @returns true if the value is an exponent of 2
  32081. */
  32082. static IsExponentOfTwo(value: number): boolean;
  32083. private static _tmpFloatArray;
  32084. /**
  32085. * Returns the nearest 32-bit single precision float representation of a Number
  32086. * @param value A Number. If the parameter is of a different type, it will get converted
  32087. * to a number or to NaN if it cannot be converted
  32088. * @returns number
  32089. */
  32090. static FloatRound(value: number): number;
  32091. /**
  32092. * Extracts the filename from a path
  32093. * @param path defines the path to use
  32094. * @returns the filename
  32095. */
  32096. static GetFilename(path: string): string;
  32097. /**
  32098. * Extracts the "folder" part of a path (everything before the filename).
  32099. * @param uri The URI to extract the info from
  32100. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32101. * @returns The "folder" part of the path
  32102. */
  32103. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32104. /**
  32105. * Extracts text content from a DOM element hierarchy
  32106. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32107. */
  32108. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32109. /**
  32110. * Convert an angle in radians to degrees
  32111. * @param angle defines the angle to convert
  32112. * @returns the angle in degrees
  32113. */
  32114. static ToDegrees(angle: number): number;
  32115. /**
  32116. * Convert an angle in degrees to radians
  32117. * @param angle defines the angle to convert
  32118. * @returns the angle in radians
  32119. */
  32120. static ToRadians(angle: number): number;
  32121. /**
  32122. * Returns an array if obj is not an array
  32123. * @param obj defines the object to evaluate as an array
  32124. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32125. * @returns either obj directly if obj is an array or a new array containing obj
  32126. */
  32127. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32128. /**
  32129. * Gets the pointer prefix to use
  32130. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32131. */
  32132. static GetPointerPrefix(): string;
  32133. /**
  32134. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32135. * @param url define the url we are trying
  32136. * @param element define the dom element where to configure the cors policy
  32137. */
  32138. static SetCorsBehavior(url: string | string[], element: {
  32139. crossOrigin: string | null;
  32140. }): void;
  32141. /**
  32142. * Removes unwanted characters from an url
  32143. * @param url defines the url to clean
  32144. * @returns the cleaned url
  32145. */
  32146. static CleanUrl(url: string): string;
  32147. /**
  32148. * Gets or sets a function used to pre-process url before using them to load assets
  32149. */
  32150. static PreprocessUrl: (url: string) => string;
  32151. /**
  32152. * Loads an image as an HTMLImageElement.
  32153. * @param input url string, ArrayBuffer, or Blob to load
  32154. * @param onLoad callback called when the image successfully loads
  32155. * @param onError callback called when the image fails to load
  32156. * @param offlineProvider offline provider for caching
  32157. * @param mimeType optional mime type
  32158. * @returns the HTMLImageElement of the loaded image
  32159. */
  32160. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32161. /**
  32162. * Loads a file from a url
  32163. * @param url url string, ArrayBuffer, or Blob to load
  32164. * @param onSuccess callback called when the file successfully loads
  32165. * @param onProgress callback called while file is loading (if the server supports this mode)
  32166. * @param offlineProvider defines the offline provider for caching
  32167. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32168. * @param onError callback called when the file fails to load
  32169. * @returns a file request object
  32170. */
  32171. 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;
  32172. /**
  32173. * Loads a file from a url
  32174. * @param url the file url to load
  32175. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32176. */
  32177. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32178. /**
  32179. * Load a script (identified by an url). When the url returns, the
  32180. * content of this file is added into a new script element, attached to the DOM (body element)
  32181. * @param scriptUrl defines the url of the script to laod
  32182. * @param onSuccess defines the callback called when the script is loaded
  32183. * @param onError defines the callback to call if an error occurs
  32184. * @param scriptId defines the id of the script element
  32185. */
  32186. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32187. /**
  32188. * Load an asynchronous script (identified by an url). When the url returns, the
  32189. * content of this file is added into a new script element, attached to the DOM (body element)
  32190. * @param scriptUrl defines the url of the script to laod
  32191. * @param scriptId defines the id of the script element
  32192. * @returns a promise request object
  32193. */
  32194. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32195. /**
  32196. * Loads a file from a blob
  32197. * @param fileToLoad defines the blob to use
  32198. * @param callback defines the callback to call when data is loaded
  32199. * @param progressCallback defines the callback to call during loading process
  32200. * @returns a file request object
  32201. */
  32202. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32203. /**
  32204. * Reads a file from a File object
  32205. * @param file defines the file to load
  32206. * @param onSuccess defines the callback to call when data is loaded
  32207. * @param onProgress defines the callback to call during loading process
  32208. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32209. * @param onError defines the callback to call when an error occurs
  32210. * @returns a file request object
  32211. */
  32212. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32213. /**
  32214. * Creates a data url from a given string content
  32215. * @param content defines the content to convert
  32216. * @returns the new data url link
  32217. */
  32218. static FileAsURL(content: string): string;
  32219. /**
  32220. * Format the given number to a specific decimal format
  32221. * @param value defines the number to format
  32222. * @param decimals defines the number of decimals to use
  32223. * @returns the formatted string
  32224. */
  32225. static Format(value: number, decimals?: number): string;
  32226. /**
  32227. * Tries to copy an object by duplicating every property
  32228. * @param source defines the source object
  32229. * @param destination defines the target object
  32230. * @param doNotCopyList defines a list of properties to avoid
  32231. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32232. */
  32233. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32234. /**
  32235. * Gets a boolean indicating if the given object has no own property
  32236. * @param obj defines the object to test
  32237. * @returns true if object has no own property
  32238. */
  32239. static IsEmpty(obj: any): boolean;
  32240. /**
  32241. * Function used to register events at window level
  32242. * @param windowElement defines the Window object to use
  32243. * @param events defines the events to register
  32244. */
  32245. static RegisterTopRootEvents(windowElement: Window, events: {
  32246. name: string;
  32247. handler: Nullable<(e: FocusEvent) => any>;
  32248. }[]): void;
  32249. /**
  32250. * Function used to unregister events from window level
  32251. * @param windowElement defines the Window object to use
  32252. * @param events defines the events to unregister
  32253. */
  32254. static UnregisterTopRootEvents(windowElement: Window, events: {
  32255. name: string;
  32256. handler: Nullable<(e: FocusEvent) => any>;
  32257. }[]): void;
  32258. /**
  32259. * @ignore
  32260. */
  32261. static _ScreenshotCanvas: HTMLCanvasElement;
  32262. /**
  32263. * Dumps the current bound framebuffer
  32264. * @param width defines the rendering width
  32265. * @param height defines the rendering height
  32266. * @param engine defines the hosting engine
  32267. * @param successCallback defines the callback triggered once the data are available
  32268. * @param mimeType defines the mime type of the result
  32269. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32270. */
  32271. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32272. /**
  32273. * Converts the canvas data to blob.
  32274. * This acts as a polyfill for browsers not supporting the to blob function.
  32275. * @param canvas Defines the canvas to extract the data from
  32276. * @param successCallback Defines the callback triggered once the data are available
  32277. * @param mimeType Defines the mime type of the result
  32278. */
  32279. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32280. /**
  32281. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32282. * @param successCallback defines the callback triggered once the data are available
  32283. * @param mimeType defines the mime type of the result
  32284. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32285. */
  32286. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32287. /**
  32288. * Downloads a blob in the browser
  32289. * @param blob defines the blob to download
  32290. * @param fileName defines the name of the downloaded file
  32291. */
  32292. static Download(blob: Blob, fileName: string): void;
  32293. /**
  32294. * Captures a screenshot of the current rendering
  32295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32296. * @param engine defines the rendering engine
  32297. * @param camera defines the source camera
  32298. * @param size This parameter can be set to a single number or to an object with the
  32299. * following (optional) properties: precision, width, height. If a single number is passed,
  32300. * it will be used for both width and height. If an object is passed, the screenshot size
  32301. * will be derived from the parameters. The precision property is a multiplier allowing
  32302. * rendering at a higher or lower resolution
  32303. * @param successCallback defines the callback receives a single parameter which contains the
  32304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32305. * src parameter of an <img> to display it
  32306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32307. * Check your browser for supported MIME types
  32308. */
  32309. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32310. /**
  32311. * Captures a screenshot of the current rendering
  32312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32313. * @param engine defines the rendering engine
  32314. * @param camera defines the source camera
  32315. * @param size This parameter can be set to a single number or to an object with the
  32316. * following (optional) properties: precision, width, height. If a single number is passed,
  32317. * it will be used for both width and height. If an object is passed, the screenshot size
  32318. * will be derived from the parameters. The precision property is a multiplier allowing
  32319. * rendering at a higher or lower resolution
  32320. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32321. * Check your browser for supported MIME types
  32322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32323. * to the src parameter of an <img> to display it
  32324. */
  32325. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32326. /**
  32327. * Generates an image screenshot from the specified camera.
  32328. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32329. * @param engine The engine to use for rendering
  32330. * @param camera The camera to use for rendering
  32331. * @param size This parameter can be set to a single number or to an object with the
  32332. * following (optional) properties: precision, width, height. If a single number is passed,
  32333. * it will be used for both width and height. If an object is passed, the screenshot size
  32334. * will be derived from the parameters. The precision property is a multiplier allowing
  32335. * rendering at a higher or lower resolution
  32336. * @param successCallback The callback receives a single parameter which contains the
  32337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32338. * src parameter of an <img> to display it
  32339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32340. * Check your browser for supported MIME types
  32341. * @param samples Texture samples (default: 1)
  32342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32343. * @param fileName A name for for the downloaded file.
  32344. */
  32345. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32346. /**
  32347. * Generates an image screenshot from the specified camera.
  32348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32349. * @param engine The engine to use for rendering
  32350. * @param camera The camera to use for rendering
  32351. * @param size This parameter can be set to a single number or to an object with the
  32352. * following (optional) properties: precision, width, height. If a single number is passed,
  32353. * it will be used for both width and height. If an object is passed, the screenshot size
  32354. * will be derived from the parameters. The precision property is a multiplier allowing
  32355. * rendering at a higher or lower resolution
  32356. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32357. * Check your browser for supported MIME types
  32358. * @param samples Texture samples (default: 1)
  32359. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32360. * @param fileName A name for for the downloaded file.
  32361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32362. * to the src parameter of an <img> to display it
  32363. */
  32364. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32365. /**
  32366. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32367. * Be aware Math.random() could cause collisions, but:
  32368. * "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"
  32369. * @returns a pseudo random id
  32370. */
  32371. static RandomId(): string;
  32372. /**
  32373. * Test if the given uri is a base64 string
  32374. * @param uri The uri to test
  32375. * @return True if the uri is a base64 string or false otherwise
  32376. */
  32377. static IsBase64(uri: string): boolean;
  32378. /**
  32379. * Decode the given base64 uri.
  32380. * @param uri The uri to decode
  32381. * @return The decoded base64 data.
  32382. */
  32383. static DecodeBase64(uri: string): ArrayBuffer;
  32384. /**
  32385. * Gets the absolute url.
  32386. * @param url the input url
  32387. * @return the absolute url
  32388. */
  32389. static GetAbsoluteUrl(url: string): string;
  32390. /**
  32391. * No log
  32392. */
  32393. static readonly NoneLogLevel: number;
  32394. /**
  32395. * Only message logs
  32396. */
  32397. static readonly MessageLogLevel: number;
  32398. /**
  32399. * Only warning logs
  32400. */
  32401. static readonly WarningLogLevel: number;
  32402. /**
  32403. * Only error logs
  32404. */
  32405. static readonly ErrorLogLevel: number;
  32406. /**
  32407. * All logs
  32408. */
  32409. static readonly AllLogLevel: number;
  32410. /**
  32411. * Gets a value indicating the number of loading errors
  32412. * @ignorenaming
  32413. */
  32414. static readonly errorsCount: number;
  32415. /**
  32416. * Callback called when a new log is added
  32417. */
  32418. static OnNewCacheEntry: (entry: string) => void;
  32419. /**
  32420. * Log a message to the console
  32421. * @param message defines the message to log
  32422. */
  32423. static Log(message: string): void;
  32424. /**
  32425. * Write a warning message to the console
  32426. * @param message defines the message to log
  32427. */
  32428. static Warn(message: string): void;
  32429. /**
  32430. * Write an error message to the console
  32431. * @param message defines the message to log
  32432. */
  32433. static Error(message: string): void;
  32434. /**
  32435. * Gets current log cache (list of logs)
  32436. */
  32437. static readonly LogCache: string;
  32438. /**
  32439. * Clears the log cache
  32440. */
  32441. static ClearLogCache(): void;
  32442. /**
  32443. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32444. */
  32445. static LogLevels: number;
  32446. /**
  32447. * Checks if the window object exists
  32448. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32449. */
  32450. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32451. /**
  32452. * No performance log
  32453. */
  32454. static readonly PerformanceNoneLogLevel: number;
  32455. /**
  32456. * Use user marks to log performance
  32457. */
  32458. static readonly PerformanceUserMarkLogLevel: number;
  32459. /**
  32460. * Log performance to the console
  32461. */
  32462. static readonly PerformanceConsoleLogLevel: number;
  32463. private static _performance;
  32464. /**
  32465. * Sets the current performance log level
  32466. */
  32467. static PerformanceLogLevel: number;
  32468. private static _StartPerformanceCounterDisabled;
  32469. private static _EndPerformanceCounterDisabled;
  32470. private static _StartUserMark;
  32471. private static _EndUserMark;
  32472. private static _StartPerformanceConsole;
  32473. private static _EndPerformanceConsole;
  32474. /**
  32475. * Starts a performance counter
  32476. */
  32477. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32478. /**
  32479. * Ends a specific performance coutner
  32480. */
  32481. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32482. /**
  32483. * Gets either window.performance.now() if supported or Date.now() else
  32484. */
  32485. static readonly Now: number;
  32486. /**
  32487. * This method will return the name of the class used to create the instance of the given object.
  32488. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32489. * @param object the object to get the class name from
  32490. * @param isType defines if the object is actually a type
  32491. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32492. */
  32493. static GetClassName(object: any, isType?: boolean): string;
  32494. /**
  32495. * Gets the first element of an array satisfying a given predicate
  32496. * @param array defines the array to browse
  32497. * @param predicate defines the predicate to use
  32498. * @returns null if not found or the element
  32499. */
  32500. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32501. /**
  32502. * This method will return the name of the full name of the class, including its owning module (if any).
  32503. * 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).
  32504. * @param object the object to get the class name from
  32505. * @param isType defines if the object is actually a type
  32506. * @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.
  32507. * @ignorenaming
  32508. */
  32509. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32510. /**
  32511. * Returns a promise that resolves after the given amount of time.
  32512. * @param delay Number of milliseconds to delay
  32513. * @returns Promise that resolves after the given amount of time
  32514. */
  32515. static DelayAsync(delay: number): Promise<void>;
  32516. }
  32517. /**
  32518. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32519. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32520. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32521. * @param name The name of the class, case should be preserved
  32522. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32523. */
  32524. export function className(name: string, module?: string): (target: Object) => void;
  32525. /**
  32526. * An implementation of a loop for asynchronous functions.
  32527. */
  32528. export class AsyncLoop {
  32529. /**
  32530. * Defines the number of iterations for the loop
  32531. */
  32532. iterations: number;
  32533. /**
  32534. * Defines the current index of the loop.
  32535. */
  32536. index: number;
  32537. private _done;
  32538. private _fn;
  32539. private _successCallback;
  32540. /**
  32541. * Constructor.
  32542. * @param iterations the number of iterations.
  32543. * @param func the function to run each iteration
  32544. * @param successCallback the callback that will be called upon succesful execution
  32545. * @param offset starting offset.
  32546. */
  32547. constructor(
  32548. /**
  32549. * Defines the number of iterations for the loop
  32550. */
  32551. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32552. /**
  32553. * Execute the next iteration. Must be called after the last iteration was finished.
  32554. */
  32555. executeNext(): void;
  32556. /**
  32557. * Break the loop and run the success callback.
  32558. */
  32559. breakLoop(): void;
  32560. /**
  32561. * Create and run an async loop.
  32562. * @param iterations the number of iterations.
  32563. * @param fn the function to run each iteration
  32564. * @param successCallback the callback that will be called upon succesful execution
  32565. * @param offset starting offset.
  32566. * @returns the created async loop object
  32567. */
  32568. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32569. /**
  32570. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32571. * @param iterations total number of iterations
  32572. * @param syncedIterations number of synchronous iterations in each async iteration.
  32573. * @param fn the function to call each iteration.
  32574. * @param callback a success call back that will be called when iterating stops.
  32575. * @param breakFunction a break condition (optional)
  32576. * @param timeout timeout settings for the setTimeout function. default - 0.
  32577. * @returns the created async loop object
  32578. */
  32579. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32580. }
  32581. }
  32582. declare module BABYLON {
  32583. /**
  32584. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32585. * The underlying implementation relies on an associative array to ensure the best performances.
  32586. * The value can be anything including 'null' but except 'undefined'
  32587. */
  32588. export class StringDictionary<T> {
  32589. /**
  32590. * This will clear this dictionary and copy the content from the 'source' one.
  32591. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32592. * @param source the dictionary to take the content from and copy to this dictionary
  32593. */
  32594. copyFrom(source: StringDictionary<T>): void;
  32595. /**
  32596. * Get a value based from its key
  32597. * @param key the given key to get the matching value from
  32598. * @return the value if found, otherwise undefined is returned
  32599. */
  32600. get(key: string): T | undefined;
  32601. /**
  32602. * Get a value from its key or add it if it doesn't exist.
  32603. * This method will ensure you that a given key/data will be present in the dictionary.
  32604. * @param key the given key to get the matching value from
  32605. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32606. * The factory will only be invoked if there's no data for the given key.
  32607. * @return the value corresponding to the key.
  32608. */
  32609. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32610. /**
  32611. * Get a value from its key if present in the dictionary otherwise add it
  32612. * @param key the key to get the value from
  32613. * @param val if there's no such key/value pair in the dictionary add it with this value
  32614. * @return the value corresponding to the key
  32615. */
  32616. getOrAdd(key: string, val: T): T;
  32617. /**
  32618. * Check if there's a given key in the dictionary
  32619. * @param key the key to check for
  32620. * @return true if the key is present, false otherwise
  32621. */
  32622. contains(key: string): boolean;
  32623. /**
  32624. * Add a new key and its corresponding value
  32625. * @param key the key to add
  32626. * @param value the value corresponding to the key
  32627. * @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
  32628. */
  32629. add(key: string, value: T): boolean;
  32630. /**
  32631. * Update a specific value associated to a key
  32632. * @param key defines the key to use
  32633. * @param value defines the value to store
  32634. * @returns true if the value was updated (or false if the key was not found)
  32635. */
  32636. set(key: string, value: T): boolean;
  32637. /**
  32638. * Get the element of the given key and remove it from the dictionary
  32639. * @param key defines the key to search
  32640. * @returns the value associated with the key or null if not found
  32641. */
  32642. getAndRemove(key: string): Nullable<T>;
  32643. /**
  32644. * Remove a key/value from the dictionary.
  32645. * @param key the key to remove
  32646. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32647. */
  32648. remove(key: string): boolean;
  32649. /**
  32650. * Clear the whole content of the dictionary
  32651. */
  32652. clear(): void;
  32653. /**
  32654. * Gets the current count
  32655. */
  32656. readonly count: number;
  32657. /**
  32658. * Execute a callback on each key/val of the dictionary.
  32659. * Note that you can remove any element in this dictionary in the callback implementation
  32660. * @param callback the callback to execute on a given key/value pair
  32661. */
  32662. forEach(callback: (key: string, val: T) => void): void;
  32663. /**
  32664. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32665. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32666. * Note that you can remove any element in this dictionary in the callback implementation
  32667. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32668. * @returns the first item
  32669. */
  32670. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32671. private _count;
  32672. private _data;
  32673. }
  32674. }
  32675. declare module BABYLON {
  32676. /** @hidden */
  32677. export interface ICollisionCoordinator {
  32678. createCollider(): Collider;
  32679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32680. init(scene: Scene): void;
  32681. }
  32682. /** @hidden */
  32683. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32684. private _scene;
  32685. private _scaledPosition;
  32686. private _scaledVelocity;
  32687. private _finalPosition;
  32688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32689. createCollider(): Collider;
  32690. init(scene: Scene): void;
  32691. private _collideWithWorld;
  32692. }
  32693. }
  32694. declare module BABYLON {
  32695. /**
  32696. * Class used to manage all inputs for the scene.
  32697. */
  32698. export class InputManager {
  32699. /** The distance in pixel that you have to move to prevent some events */
  32700. static DragMovementThreshold: number;
  32701. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32702. static LongPressDelay: number;
  32703. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32704. static DoubleClickDelay: number;
  32705. /** If you need to check double click without raising a single click at first click, enable this flag */
  32706. static ExclusiveDoubleClickMode: boolean;
  32707. private _wheelEventName;
  32708. private _onPointerMove;
  32709. private _onPointerDown;
  32710. private _onPointerUp;
  32711. private _initClickEvent;
  32712. private _initActionManager;
  32713. private _delayedSimpleClick;
  32714. private _delayedSimpleClickTimeout;
  32715. private _previousDelayedSimpleClickTimeout;
  32716. private _meshPickProceed;
  32717. private _previousButtonPressed;
  32718. private _currentPickResult;
  32719. private _previousPickResult;
  32720. private _totalPointersPressed;
  32721. private _doubleClickOccured;
  32722. private _pointerOverMesh;
  32723. private _pickedDownMesh;
  32724. private _pickedUpMesh;
  32725. private _pointerX;
  32726. private _pointerY;
  32727. private _unTranslatedPointerX;
  32728. private _unTranslatedPointerY;
  32729. private _startingPointerPosition;
  32730. private _previousStartingPointerPosition;
  32731. private _startingPointerTime;
  32732. private _previousStartingPointerTime;
  32733. private _pointerCaptures;
  32734. private _onKeyDown;
  32735. private _onKeyUp;
  32736. private _onCanvasFocusObserver;
  32737. private _onCanvasBlurObserver;
  32738. private _scene;
  32739. /**
  32740. * Creates a new InputManager
  32741. * @param scene defines the hosting scene
  32742. */
  32743. constructor(scene: Scene);
  32744. /**
  32745. * Gets the mesh that is currently under the pointer
  32746. */
  32747. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32748. /**
  32749. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32750. */
  32751. readonly unTranslatedPointer: Vector2;
  32752. /**
  32753. * Gets or sets the current on-screen X position of the pointer
  32754. */
  32755. pointerX: number;
  32756. /**
  32757. * Gets or sets the current on-screen Y position of the pointer
  32758. */
  32759. pointerY: number;
  32760. private _updatePointerPosition;
  32761. private _processPointerMove;
  32762. private _setRayOnPointerInfo;
  32763. private _checkPrePointerObservable;
  32764. /**
  32765. * Use this method to simulate a pointer move on a mesh
  32766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32769. */
  32770. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32771. /**
  32772. * Use this method to simulate a pointer down on a mesh
  32773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32776. */
  32777. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32778. private _processPointerDown;
  32779. /** @hidden */
  32780. _isPointerSwiping(): boolean;
  32781. /**
  32782. * Use this method to simulate a pointer up on a mesh
  32783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32787. */
  32788. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32789. private _processPointerUp;
  32790. /**
  32791. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32792. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32793. * @returns true if the pointer was captured
  32794. */
  32795. isPointerCaptured(pointerId?: number): boolean;
  32796. /**
  32797. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32798. * @param attachUp defines if you want to attach events to pointerup
  32799. * @param attachDown defines if you want to attach events to pointerdown
  32800. * @param attachMove defines if you want to attach events to pointermove
  32801. */
  32802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32803. /**
  32804. * Detaches all event handlers
  32805. */
  32806. detachControl(): void;
  32807. /**
  32808. * Force the value of meshUnderPointer
  32809. * @param mesh defines the mesh to use
  32810. */
  32811. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32812. /**
  32813. * Gets the mesh under the pointer
  32814. * @returns a Mesh or null if no mesh is under the pointer
  32815. */
  32816. getPointerOverMesh(): Nullable<AbstractMesh>;
  32817. }
  32818. }
  32819. declare module BABYLON {
  32820. /**
  32821. * Helper class used to generate session unique ID
  32822. */
  32823. export class UniqueIdGenerator {
  32824. private static _UniqueIdCounter;
  32825. /**
  32826. * Gets an unique (relatively to the current scene) Id
  32827. */
  32828. static readonly UniqueId: number;
  32829. }
  32830. }
  32831. declare module BABYLON {
  32832. /**
  32833. * This class defines the direct association between an animation and a target
  32834. */
  32835. export class TargetedAnimation {
  32836. /**
  32837. * Animation to perform
  32838. */
  32839. animation: Animation;
  32840. /**
  32841. * Target to animate
  32842. */
  32843. target: any;
  32844. /**
  32845. * Serialize the object
  32846. * @returns the JSON object representing the current entity
  32847. */
  32848. serialize(): any;
  32849. }
  32850. /**
  32851. * Use this class to create coordinated animations on multiple targets
  32852. */
  32853. export class AnimationGroup implements IDisposable {
  32854. /** The name of the animation group */
  32855. name: string;
  32856. private _scene;
  32857. private _targetedAnimations;
  32858. private _animatables;
  32859. private _from;
  32860. private _to;
  32861. private _isStarted;
  32862. private _isPaused;
  32863. private _speedRatio;
  32864. private _loopAnimation;
  32865. /**
  32866. * Gets or sets the unique id of the node
  32867. */
  32868. uniqueId: number;
  32869. /**
  32870. * This observable will notify when one animation have ended
  32871. */
  32872. onAnimationEndObservable: Observable<TargetedAnimation>;
  32873. /**
  32874. * Observer raised when one animation loops
  32875. */
  32876. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32877. /**
  32878. * Observer raised when all animations have looped
  32879. */
  32880. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  32881. /**
  32882. * This observable will notify when all animations have ended.
  32883. */
  32884. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32885. /**
  32886. * This observable will notify when all animations have paused.
  32887. */
  32888. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32889. /**
  32890. * This observable will notify when all animations are playing.
  32891. */
  32892. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32893. /**
  32894. * Gets the first frame
  32895. */
  32896. readonly from: number;
  32897. /**
  32898. * Gets the last frame
  32899. */
  32900. readonly to: number;
  32901. /**
  32902. * Define if the animations are started
  32903. */
  32904. readonly isStarted: boolean;
  32905. /**
  32906. * Gets a value indicating that the current group is playing
  32907. */
  32908. readonly isPlaying: boolean;
  32909. /**
  32910. * Gets or sets the speed ratio to use for all animations
  32911. */
  32912. /**
  32913. * Gets or sets the speed ratio to use for all animations
  32914. */
  32915. speedRatio: number;
  32916. /**
  32917. * Gets or sets if all animations should loop or not
  32918. */
  32919. loopAnimation: boolean;
  32920. /**
  32921. * Gets the targeted animations for this animation group
  32922. */
  32923. readonly targetedAnimations: Array<TargetedAnimation>;
  32924. /**
  32925. * returning the list of animatables controlled by this animation group.
  32926. */
  32927. readonly animatables: Array<Animatable>;
  32928. /**
  32929. * Instantiates a new Animation Group.
  32930. * This helps managing several animations at once.
  32931. * @see http://doc.babylonjs.com/how_to/group
  32932. * @param name Defines the name of the group
  32933. * @param scene Defines the scene the group belongs to
  32934. */
  32935. constructor(
  32936. /** The name of the animation group */
  32937. name: string, scene?: Nullable<Scene>);
  32938. /**
  32939. * Add an animation (with its target) in the group
  32940. * @param animation defines the animation we want to add
  32941. * @param target defines the target of the animation
  32942. * @returns the TargetedAnimation object
  32943. */
  32944. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32945. /**
  32946. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32947. * It can add constant keys at begin or end
  32948. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32949. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32950. * @returns the animation group
  32951. */
  32952. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32953. private _animationLoopCount;
  32954. private _animationLoopFlags;
  32955. private _processLoop;
  32956. /**
  32957. * Start all animations on given targets
  32958. * @param loop defines if animations must loop
  32959. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32960. * @param from defines the from key (optional)
  32961. * @param to defines the to key (optional)
  32962. * @returns the current animation group
  32963. */
  32964. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32965. /**
  32966. * Pause all animations
  32967. * @returns the animation group
  32968. */
  32969. pause(): AnimationGroup;
  32970. /**
  32971. * Play all animations to initial state
  32972. * This function will start() the animations if they were not started or will restart() them if they were paused
  32973. * @param loop defines if animations must loop
  32974. * @returns the animation group
  32975. */
  32976. play(loop?: boolean): AnimationGroup;
  32977. /**
  32978. * Reset all animations to initial state
  32979. * @returns the animation group
  32980. */
  32981. reset(): AnimationGroup;
  32982. /**
  32983. * Restart animations from key 0
  32984. * @returns the animation group
  32985. */
  32986. restart(): AnimationGroup;
  32987. /**
  32988. * Stop all animations
  32989. * @returns the animation group
  32990. */
  32991. stop(): AnimationGroup;
  32992. /**
  32993. * Set animation weight for all animatables
  32994. * @param weight defines the weight to use
  32995. * @return the animationGroup
  32996. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32997. */
  32998. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32999. /**
  33000. * Synchronize and normalize all animatables with a source animatable
  33001. * @param root defines the root animatable to synchronize with
  33002. * @return the animationGroup
  33003. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33004. */
  33005. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33006. /**
  33007. * Goes to a specific frame in this animation group
  33008. * @param frame the frame number to go to
  33009. * @return the animationGroup
  33010. */
  33011. goToFrame(frame: number): AnimationGroup;
  33012. /**
  33013. * Dispose all associated resources
  33014. */
  33015. dispose(): void;
  33016. private _checkAnimationGroupEnded;
  33017. /**
  33018. * Clone the current animation group and returns a copy
  33019. * @param newName defines the name of the new group
  33020. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33021. * @returns the new aniamtion group
  33022. */
  33023. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33024. /**
  33025. * Serializes the animationGroup to an object
  33026. * @returns Serialized object
  33027. */
  33028. serialize(): any;
  33029. /**
  33030. * Returns a new AnimationGroup object parsed from the source provided.
  33031. * @param parsedAnimationGroup defines the source
  33032. * @param scene defines the scene that will receive the animationGroup
  33033. * @returns a new AnimationGroup
  33034. */
  33035. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33036. /**
  33037. * Returns the string "AnimationGroup"
  33038. * @returns "AnimationGroup"
  33039. */
  33040. getClassName(): string;
  33041. /**
  33042. * Creates a detailled string about the object
  33043. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33044. * @returns a string representing the object
  33045. */
  33046. toString(fullDetails?: boolean): string;
  33047. }
  33048. }
  33049. declare module BABYLON {
  33050. /**
  33051. * Define an interface for all classes that will hold resources
  33052. */
  33053. export interface IDisposable {
  33054. /**
  33055. * Releases all held resources
  33056. */
  33057. dispose(): void;
  33058. }
  33059. /** Interface defining initialization parameters for Scene class */
  33060. export interface SceneOptions {
  33061. /**
  33062. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33063. * It will improve performance when the number of geometries becomes important.
  33064. */
  33065. useGeometryUniqueIdsMap?: boolean;
  33066. /**
  33067. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33068. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33069. */
  33070. useMaterialMeshMap?: boolean;
  33071. /**
  33072. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33073. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33074. */
  33075. useClonedMeshhMap?: boolean;
  33076. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33077. virtual?: boolean;
  33078. }
  33079. /**
  33080. * Represents a scene to be rendered by the engine.
  33081. * @see http://doc.babylonjs.com/features/scene
  33082. */
  33083. export class Scene extends AbstractScene implements IAnimatable {
  33084. /** The fog is deactivated */
  33085. static readonly FOGMODE_NONE: number;
  33086. /** The fog density is following an exponential function */
  33087. static readonly FOGMODE_EXP: number;
  33088. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33089. static readonly FOGMODE_EXP2: number;
  33090. /** The fog density is following a linear function. */
  33091. static readonly FOGMODE_LINEAR: number;
  33092. /**
  33093. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33094. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33095. */
  33096. static MinDeltaTime: number;
  33097. /**
  33098. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33100. */
  33101. static MaxDeltaTime: number;
  33102. /**
  33103. * Factory used to create the default material.
  33104. * @param name The name of the material to create
  33105. * @param scene The scene to create the material for
  33106. * @returns The default material
  33107. */
  33108. static DefaultMaterialFactory(scene: Scene): Material;
  33109. /**
  33110. * Factory used to create the a collision coordinator.
  33111. * @returns The collision coordinator
  33112. */
  33113. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33114. /** @hidden */
  33115. _inputManager: InputManager;
  33116. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33117. cameraToUseForPointers: Nullable<Camera>;
  33118. /** @hidden */
  33119. readonly _isScene: boolean;
  33120. /**
  33121. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33122. */
  33123. autoClear: boolean;
  33124. /**
  33125. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33126. */
  33127. autoClearDepthAndStencil: boolean;
  33128. /**
  33129. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33130. */
  33131. clearColor: Color4;
  33132. /**
  33133. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33134. */
  33135. ambientColor: Color3;
  33136. /**
  33137. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33138. * It should only be one of the following (if not the default embedded one):
  33139. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33140. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33141. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33142. * The material properties need to be setup according to the type of texture in use.
  33143. */
  33144. environmentBRDFTexture: BaseTexture;
  33145. /** @hidden */
  33146. protected _environmentTexture: Nullable<BaseTexture>;
  33147. /**
  33148. * Texture used in all pbr material as the reflection texture.
  33149. * As in the majority of the scene they are the same (exception for multi room and so on),
  33150. * this is easier to reference from here than from all the materials.
  33151. */
  33152. /**
  33153. * Texture used in all pbr material as the reflection texture.
  33154. * As in the majority of the scene they are the same (exception for multi room and so on),
  33155. * this is easier to set here than in all the materials.
  33156. */
  33157. environmentTexture: Nullable<BaseTexture>;
  33158. /** @hidden */
  33159. protected _environmentIntensity: number;
  33160. /**
  33161. * Intensity of the environment in all pbr material.
  33162. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33163. * As in the majority of the scene they are the same (exception for multi room and so on),
  33164. * this is easier to reference from here than from all the materials.
  33165. */
  33166. /**
  33167. * Intensity of the environment in all pbr material.
  33168. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33169. * As in the majority of the scene they are the same (exception for multi room and so on),
  33170. * this is easier to set here than in all the materials.
  33171. */
  33172. environmentIntensity: number;
  33173. /** @hidden */
  33174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33175. /**
  33176. * Default image processing configuration used either in the rendering
  33177. * Forward main pass or through the imageProcessingPostProcess if present.
  33178. * As in the majority of the scene they are the same (exception for multi camera),
  33179. * this is easier to reference from here than from all the materials and post process.
  33180. *
  33181. * No setter as we it is a shared configuration, you can set the values instead.
  33182. */
  33183. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33184. private _forceWireframe;
  33185. /**
  33186. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33187. */
  33188. forceWireframe: boolean;
  33189. private _forcePointsCloud;
  33190. /**
  33191. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33192. */
  33193. forcePointsCloud: boolean;
  33194. /**
  33195. * Gets or sets the active clipplane 1
  33196. */
  33197. clipPlane: Nullable<Plane>;
  33198. /**
  33199. * Gets or sets the active clipplane 2
  33200. */
  33201. clipPlane2: Nullable<Plane>;
  33202. /**
  33203. * Gets or sets the active clipplane 3
  33204. */
  33205. clipPlane3: Nullable<Plane>;
  33206. /**
  33207. * Gets or sets the active clipplane 4
  33208. */
  33209. clipPlane4: Nullable<Plane>;
  33210. /**
  33211. * Gets or sets a boolean indicating if animations are enabled
  33212. */
  33213. animationsEnabled: boolean;
  33214. private _animationPropertiesOverride;
  33215. /**
  33216. * Gets or sets the animation properties override
  33217. */
  33218. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33219. /**
  33220. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33221. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33222. */
  33223. useConstantAnimationDeltaTime: boolean;
  33224. /**
  33225. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33226. * Please note that it requires to run a ray cast through the scene on every frame
  33227. */
  33228. constantlyUpdateMeshUnderPointer: boolean;
  33229. /**
  33230. * Defines the HTML cursor to use when hovering over interactive elements
  33231. */
  33232. hoverCursor: string;
  33233. /**
  33234. * Defines the HTML default cursor to use (empty by default)
  33235. */
  33236. defaultCursor: string;
  33237. /**
  33238. * Defines wether cursors are handled by the scene.
  33239. */
  33240. doNotHandleCursors: boolean;
  33241. /**
  33242. * This is used to call preventDefault() on pointer down
  33243. * in order to block unwanted artifacts like system double clicks
  33244. */
  33245. preventDefaultOnPointerDown: boolean;
  33246. /**
  33247. * This is used to call preventDefault() on pointer up
  33248. * in order to block unwanted artifacts like system double clicks
  33249. */
  33250. preventDefaultOnPointerUp: boolean;
  33251. /**
  33252. * Gets or sets user defined metadata
  33253. */
  33254. metadata: any;
  33255. /**
  33256. * For internal use only. Please do not use.
  33257. */
  33258. reservedDataStore: any;
  33259. /**
  33260. * Gets the name of the plugin used to load this scene (null by default)
  33261. */
  33262. loadingPluginName: string;
  33263. /**
  33264. * Use this array to add regular expressions used to disable offline support for specific urls
  33265. */
  33266. disableOfflineSupportExceptionRules: RegExp[];
  33267. /**
  33268. * An event triggered when the scene is disposed.
  33269. */
  33270. onDisposeObservable: Observable<Scene>;
  33271. private _onDisposeObserver;
  33272. /** Sets a function to be executed when this scene is disposed. */
  33273. onDispose: () => void;
  33274. /**
  33275. * An event triggered before rendering the scene (right after animations and physics)
  33276. */
  33277. onBeforeRenderObservable: Observable<Scene>;
  33278. private _onBeforeRenderObserver;
  33279. /** Sets a function to be executed before rendering this scene */
  33280. beforeRender: Nullable<() => void>;
  33281. /**
  33282. * An event triggered after rendering the scene
  33283. */
  33284. onAfterRenderObservable: Observable<Scene>;
  33285. /**
  33286. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33287. */
  33288. onAfterRenderCameraObservable: Observable<Camera>;
  33289. private _onAfterRenderObserver;
  33290. /** Sets a function to be executed after rendering this scene */
  33291. afterRender: Nullable<() => void>;
  33292. /**
  33293. * An event triggered before animating the scene
  33294. */
  33295. onBeforeAnimationsObservable: Observable<Scene>;
  33296. /**
  33297. * An event triggered after animations processing
  33298. */
  33299. onAfterAnimationsObservable: Observable<Scene>;
  33300. /**
  33301. * An event triggered before draw calls are ready to be sent
  33302. */
  33303. onBeforeDrawPhaseObservable: Observable<Scene>;
  33304. /**
  33305. * An event triggered after draw calls have been sent
  33306. */
  33307. onAfterDrawPhaseObservable: Observable<Scene>;
  33308. /**
  33309. * An event triggered when the scene is ready
  33310. */
  33311. onReadyObservable: Observable<Scene>;
  33312. /**
  33313. * An event triggered before rendering a camera
  33314. */
  33315. onBeforeCameraRenderObservable: Observable<Camera>;
  33316. private _onBeforeCameraRenderObserver;
  33317. /** Sets a function to be executed before rendering a camera*/
  33318. beforeCameraRender: () => void;
  33319. /**
  33320. * An event triggered after rendering a camera
  33321. */
  33322. onAfterCameraRenderObservable: Observable<Camera>;
  33323. private _onAfterCameraRenderObserver;
  33324. /** Sets a function to be executed after rendering a camera*/
  33325. afterCameraRender: () => void;
  33326. /**
  33327. * An event triggered when active meshes evaluation is about to start
  33328. */
  33329. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33330. /**
  33331. * An event triggered when active meshes evaluation is done
  33332. */
  33333. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33334. /**
  33335. * An event triggered when particles rendering is about to start
  33336. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33337. */
  33338. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33339. /**
  33340. * An event triggered when particles rendering is done
  33341. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33342. */
  33343. onAfterParticlesRenderingObservable: Observable<Scene>;
  33344. /**
  33345. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33346. */
  33347. onDataLoadedObservable: Observable<Scene>;
  33348. /**
  33349. * An event triggered when a camera is created
  33350. */
  33351. onNewCameraAddedObservable: Observable<Camera>;
  33352. /**
  33353. * An event triggered when a camera is removed
  33354. */
  33355. onCameraRemovedObservable: Observable<Camera>;
  33356. /**
  33357. * An event triggered when a light is created
  33358. */
  33359. onNewLightAddedObservable: Observable<Light>;
  33360. /**
  33361. * An event triggered when a light is removed
  33362. */
  33363. onLightRemovedObservable: Observable<Light>;
  33364. /**
  33365. * An event triggered when a geometry is created
  33366. */
  33367. onNewGeometryAddedObservable: Observable<Geometry>;
  33368. /**
  33369. * An event triggered when a geometry is removed
  33370. */
  33371. onGeometryRemovedObservable: Observable<Geometry>;
  33372. /**
  33373. * An event triggered when a transform node is created
  33374. */
  33375. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33376. /**
  33377. * An event triggered when a transform node is removed
  33378. */
  33379. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33380. /**
  33381. * An event triggered when a mesh is created
  33382. */
  33383. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33384. /**
  33385. * An event triggered when a mesh is removed
  33386. */
  33387. onMeshRemovedObservable: Observable<AbstractMesh>;
  33388. /**
  33389. * An event triggered when a skeleton is created
  33390. */
  33391. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33392. /**
  33393. * An event triggered when a skeleton is removed
  33394. */
  33395. onSkeletonRemovedObservable: Observable<Skeleton>;
  33396. /**
  33397. * An event triggered when a material is created
  33398. */
  33399. onNewMaterialAddedObservable: Observable<Material>;
  33400. /**
  33401. * An event triggered when a material is removed
  33402. */
  33403. onMaterialRemovedObservable: Observable<Material>;
  33404. /**
  33405. * An event triggered when a texture is created
  33406. */
  33407. onNewTextureAddedObservable: Observable<BaseTexture>;
  33408. /**
  33409. * An event triggered when a texture is removed
  33410. */
  33411. onTextureRemovedObservable: Observable<BaseTexture>;
  33412. /**
  33413. * An event triggered when render targets are about to be rendered
  33414. * Can happen multiple times per frame.
  33415. */
  33416. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33417. /**
  33418. * An event triggered when render targets were rendered.
  33419. * Can happen multiple times per frame.
  33420. */
  33421. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33422. /**
  33423. * An event triggered before calculating deterministic simulation step
  33424. */
  33425. onBeforeStepObservable: Observable<Scene>;
  33426. /**
  33427. * An event triggered after calculating deterministic simulation step
  33428. */
  33429. onAfterStepObservable: Observable<Scene>;
  33430. /**
  33431. * An event triggered when the activeCamera property is updated
  33432. */
  33433. onActiveCameraChanged: Observable<Scene>;
  33434. /**
  33435. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33436. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33437. * 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)
  33438. */
  33439. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33440. /**
  33441. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33442. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33443. * 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)
  33444. */
  33445. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33446. /**
  33447. * This Observable will when a mesh has been imported into the scene.
  33448. */
  33449. onMeshImportedObservable: Observable<AbstractMesh>;
  33450. /**
  33451. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33452. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33453. */
  33454. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33455. /** @hidden */
  33456. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33457. /**
  33458. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33459. */
  33460. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33461. /**
  33462. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33463. */
  33464. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33465. /**
  33466. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33467. */
  33468. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33469. /** Callback called when a pointer move is detected */
  33470. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33471. /** Callback called when a pointer down is detected */
  33472. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33473. /** Callback called when a pointer up is detected */
  33474. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33475. /** Callback called when a pointer pick is detected */
  33476. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33477. /**
  33478. * 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).
  33479. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33480. */
  33481. onPrePointerObservable: Observable<PointerInfoPre>;
  33482. /**
  33483. * Observable event triggered each time an input event is received from the rendering canvas
  33484. */
  33485. onPointerObservable: Observable<PointerInfo>;
  33486. /**
  33487. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33488. */
  33489. readonly unTranslatedPointer: Vector2;
  33490. /**
  33491. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33492. */
  33493. static DragMovementThreshold: number;
  33494. /**
  33495. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33496. */
  33497. static LongPressDelay: number;
  33498. /**
  33499. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33500. */
  33501. static DoubleClickDelay: number;
  33502. /** If you need to check double click without raising a single click at first click, enable this flag */
  33503. static ExclusiveDoubleClickMode: boolean;
  33504. /** @hidden */
  33505. _mirroredCameraPosition: Nullable<Vector3>;
  33506. /**
  33507. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33508. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33509. */
  33510. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33511. /**
  33512. * Observable event triggered each time an keyboard event is received from the hosting window
  33513. */
  33514. onKeyboardObservable: Observable<KeyboardInfo>;
  33515. private _useRightHandedSystem;
  33516. /**
  33517. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33518. */
  33519. useRightHandedSystem: boolean;
  33520. private _timeAccumulator;
  33521. private _currentStepId;
  33522. private _currentInternalStep;
  33523. /**
  33524. * Sets the step Id used by deterministic lock step
  33525. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33526. * @param newStepId defines the step Id
  33527. */
  33528. setStepId(newStepId: number): void;
  33529. /**
  33530. * Gets the step Id used by deterministic lock step
  33531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33532. * @returns the step Id
  33533. */
  33534. getStepId(): number;
  33535. /**
  33536. * Gets the internal step used by deterministic lock step
  33537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33538. * @returns the internal step
  33539. */
  33540. getInternalStep(): number;
  33541. private _fogEnabled;
  33542. /**
  33543. * Gets or sets a boolean indicating if fog is enabled on this scene
  33544. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33545. * (Default is true)
  33546. */
  33547. fogEnabled: boolean;
  33548. private _fogMode;
  33549. /**
  33550. * Gets or sets the fog mode to use
  33551. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33552. * | mode | value |
  33553. * | --- | --- |
  33554. * | FOGMODE_NONE | 0 |
  33555. * | FOGMODE_EXP | 1 |
  33556. * | FOGMODE_EXP2 | 2 |
  33557. * | FOGMODE_LINEAR | 3 |
  33558. */
  33559. fogMode: number;
  33560. /**
  33561. * Gets or sets the fog color to use
  33562. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33563. * (Default is Color3(0.2, 0.2, 0.3))
  33564. */
  33565. fogColor: Color3;
  33566. /**
  33567. * Gets or sets the fog density to use
  33568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33569. * (Default is 0.1)
  33570. */
  33571. fogDensity: number;
  33572. /**
  33573. * Gets or sets the fog start distance to use
  33574. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33575. * (Default is 0)
  33576. */
  33577. fogStart: number;
  33578. /**
  33579. * Gets or sets the fog end distance to use
  33580. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33581. * (Default is 1000)
  33582. */
  33583. fogEnd: number;
  33584. private _shadowsEnabled;
  33585. /**
  33586. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33587. */
  33588. shadowsEnabled: boolean;
  33589. private _lightsEnabled;
  33590. /**
  33591. * Gets or sets a boolean indicating if lights are enabled on this scene
  33592. */
  33593. lightsEnabled: boolean;
  33594. /** All of the active cameras added to this scene. */
  33595. activeCameras: Camera[];
  33596. /** @hidden */
  33597. _activeCamera: Nullable<Camera>;
  33598. /** Gets or sets the current active camera */
  33599. activeCamera: Nullable<Camera>;
  33600. private _defaultMaterial;
  33601. /** The default material used on meshes when no material is affected */
  33602. /** The default material used on meshes when no material is affected */
  33603. defaultMaterial: Material;
  33604. private _texturesEnabled;
  33605. /**
  33606. * Gets or sets a boolean indicating if textures are enabled on this scene
  33607. */
  33608. texturesEnabled: boolean;
  33609. /**
  33610. * Gets or sets a boolean indicating if particles are enabled on this scene
  33611. */
  33612. particlesEnabled: boolean;
  33613. /**
  33614. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33615. */
  33616. spritesEnabled: boolean;
  33617. private _skeletonsEnabled;
  33618. /**
  33619. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33620. */
  33621. skeletonsEnabled: boolean;
  33622. /**
  33623. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33624. */
  33625. lensFlaresEnabled: boolean;
  33626. /**
  33627. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33628. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33629. */
  33630. collisionsEnabled: boolean;
  33631. private _collisionCoordinator;
  33632. /** @hidden */
  33633. readonly collisionCoordinator: ICollisionCoordinator;
  33634. /**
  33635. * Defines the gravity applied to this scene (used only for collisions)
  33636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33637. */
  33638. gravity: Vector3;
  33639. /**
  33640. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33641. */
  33642. postProcessesEnabled: boolean;
  33643. /**
  33644. * The list of postprocesses added to the scene
  33645. */
  33646. postProcesses: PostProcess[];
  33647. /**
  33648. * Gets the current postprocess manager
  33649. */
  33650. postProcessManager: PostProcessManager;
  33651. /**
  33652. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33653. */
  33654. renderTargetsEnabled: boolean;
  33655. /**
  33656. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33657. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33658. */
  33659. dumpNextRenderTargets: boolean;
  33660. /**
  33661. * The list of user defined render targets added to the scene
  33662. */
  33663. customRenderTargets: RenderTargetTexture[];
  33664. /**
  33665. * Defines if texture loading must be delayed
  33666. * If true, textures will only be loaded when they need to be rendered
  33667. */
  33668. useDelayedTextureLoading: boolean;
  33669. /**
  33670. * Gets the list of meshes imported to the scene through SceneLoader
  33671. */
  33672. importedMeshesFiles: String[];
  33673. /**
  33674. * Gets or sets a boolean indicating if probes are enabled on this scene
  33675. */
  33676. probesEnabled: boolean;
  33677. /**
  33678. * Gets or sets the current offline provider to use to store scene data
  33679. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33680. */
  33681. offlineProvider: IOfflineProvider;
  33682. /**
  33683. * Gets or sets the action manager associated with the scene
  33684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33685. */
  33686. actionManager: AbstractActionManager;
  33687. private _meshesForIntersections;
  33688. /**
  33689. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33690. */
  33691. proceduralTexturesEnabled: boolean;
  33692. private _engine;
  33693. private _totalVertices;
  33694. /** @hidden */
  33695. _activeIndices: PerfCounter;
  33696. /** @hidden */
  33697. _activeParticles: PerfCounter;
  33698. /** @hidden */
  33699. _activeBones: PerfCounter;
  33700. private _animationRatio;
  33701. /** @hidden */
  33702. _animationTimeLast: number;
  33703. /** @hidden */
  33704. _animationTime: number;
  33705. /**
  33706. * Gets or sets a general scale for animation speed
  33707. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33708. */
  33709. animationTimeScale: number;
  33710. /** @hidden */
  33711. _cachedMaterial: Nullable<Material>;
  33712. /** @hidden */
  33713. _cachedEffect: Nullable<Effect>;
  33714. /** @hidden */
  33715. _cachedVisibility: Nullable<number>;
  33716. private _renderId;
  33717. private _frameId;
  33718. private _executeWhenReadyTimeoutId;
  33719. private _intermediateRendering;
  33720. private _viewUpdateFlag;
  33721. private _projectionUpdateFlag;
  33722. /** @hidden */
  33723. _toBeDisposed: Nullable<IDisposable>[];
  33724. private _activeRequests;
  33725. /** @hidden */
  33726. _pendingData: any[];
  33727. private _isDisposed;
  33728. /**
  33729. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33730. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33731. */
  33732. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33733. private _activeMeshes;
  33734. private _processedMaterials;
  33735. private _renderTargets;
  33736. /** @hidden */
  33737. _activeParticleSystems: SmartArray<IParticleSystem>;
  33738. private _activeSkeletons;
  33739. private _softwareSkinnedMeshes;
  33740. private _renderingManager;
  33741. /** @hidden */
  33742. _activeAnimatables: Animatable[];
  33743. private _transformMatrix;
  33744. private _sceneUbo;
  33745. /** @hidden */
  33746. _viewMatrix: Matrix;
  33747. private _projectionMatrix;
  33748. /** @hidden */
  33749. _forcedViewPosition: Nullable<Vector3>;
  33750. /** @hidden */
  33751. _frustumPlanes: Plane[];
  33752. /**
  33753. * Gets the list of frustum planes (built from the active camera)
  33754. */
  33755. readonly frustumPlanes: Plane[];
  33756. /**
  33757. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33758. * This is useful if there are more lights that the maximum simulteanous authorized
  33759. */
  33760. requireLightSorting: boolean;
  33761. /** @hidden */
  33762. readonly useMaterialMeshMap: boolean;
  33763. /** @hidden */
  33764. readonly useClonedMeshhMap: boolean;
  33765. private _externalData;
  33766. private _uid;
  33767. /**
  33768. * @hidden
  33769. * Backing store of defined scene components.
  33770. */
  33771. _components: ISceneComponent[];
  33772. /**
  33773. * @hidden
  33774. * Backing store of defined scene components.
  33775. */
  33776. _serializableComponents: ISceneSerializableComponent[];
  33777. /**
  33778. * List of components to register on the next registration step.
  33779. */
  33780. private _transientComponents;
  33781. /**
  33782. * Registers the transient components if needed.
  33783. */
  33784. private _registerTransientComponents;
  33785. /**
  33786. * @hidden
  33787. * Add a component to the scene.
  33788. * Note that the ccomponent could be registered on th next frame if this is called after
  33789. * the register component stage.
  33790. * @param component Defines the component to add to the scene
  33791. */
  33792. _addComponent(component: ISceneComponent): void;
  33793. /**
  33794. * @hidden
  33795. * Gets a component from the scene.
  33796. * @param name defines the name of the component to retrieve
  33797. * @returns the component or null if not present
  33798. */
  33799. _getComponent(name: string): Nullable<ISceneComponent>;
  33800. /**
  33801. * @hidden
  33802. * Defines the actions happening before camera updates.
  33803. */
  33804. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33805. /**
  33806. * @hidden
  33807. * Defines the actions happening before clear the canvas.
  33808. */
  33809. _beforeClearStage: Stage<SimpleStageAction>;
  33810. /**
  33811. * @hidden
  33812. * Defines the actions when collecting render targets for the frame.
  33813. */
  33814. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33815. /**
  33816. * @hidden
  33817. * Defines the actions happening for one camera in the frame.
  33818. */
  33819. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33820. /**
  33821. * @hidden
  33822. * Defines the actions happening during the per mesh ready checks.
  33823. */
  33824. _isReadyForMeshStage: Stage<MeshStageAction>;
  33825. /**
  33826. * @hidden
  33827. * Defines the actions happening before evaluate active mesh checks.
  33828. */
  33829. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33830. /**
  33831. * @hidden
  33832. * Defines the actions happening during the evaluate sub mesh checks.
  33833. */
  33834. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33835. /**
  33836. * @hidden
  33837. * Defines the actions happening during the active mesh stage.
  33838. */
  33839. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33840. /**
  33841. * @hidden
  33842. * Defines the actions happening during the per camera render target step.
  33843. */
  33844. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33845. /**
  33846. * @hidden
  33847. * Defines the actions happening just before the active camera is drawing.
  33848. */
  33849. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33850. /**
  33851. * @hidden
  33852. * Defines the actions happening just before a render target is drawing.
  33853. */
  33854. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33855. /**
  33856. * @hidden
  33857. * Defines the actions happening just before a rendering group is drawing.
  33858. */
  33859. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33860. /**
  33861. * @hidden
  33862. * Defines the actions happening just before a mesh is drawing.
  33863. */
  33864. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33865. /**
  33866. * @hidden
  33867. * Defines the actions happening just after a mesh has been drawn.
  33868. */
  33869. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33870. /**
  33871. * @hidden
  33872. * Defines the actions happening just after a rendering group has been drawn.
  33873. */
  33874. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33875. /**
  33876. * @hidden
  33877. * Defines the actions happening just after the active camera has been drawn.
  33878. */
  33879. _afterCameraDrawStage: Stage<CameraStageAction>;
  33880. /**
  33881. * @hidden
  33882. * Defines the actions happening just after a render target has been drawn.
  33883. */
  33884. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33885. /**
  33886. * @hidden
  33887. * Defines the actions happening just after rendering all cameras and computing intersections.
  33888. */
  33889. _afterRenderStage: Stage<SimpleStageAction>;
  33890. /**
  33891. * @hidden
  33892. * Defines the actions happening when a pointer move event happens.
  33893. */
  33894. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33895. /**
  33896. * @hidden
  33897. * Defines the actions happening when a pointer down event happens.
  33898. */
  33899. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33900. /**
  33901. * @hidden
  33902. * Defines the actions happening when a pointer up event happens.
  33903. */
  33904. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33905. /**
  33906. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33907. */
  33908. private geometriesByUniqueId;
  33909. /**
  33910. * Creates a new Scene
  33911. * @param engine defines the engine to use to render this scene
  33912. * @param options defines the scene options
  33913. */
  33914. constructor(engine: Engine, options?: SceneOptions);
  33915. /**
  33916. * Gets a string idenfifying the name of the class
  33917. * @returns "Scene" string
  33918. */
  33919. getClassName(): string;
  33920. private _defaultMeshCandidates;
  33921. /**
  33922. * @hidden
  33923. */
  33924. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33925. private _defaultSubMeshCandidates;
  33926. /**
  33927. * @hidden
  33928. */
  33929. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33930. /**
  33931. * Sets the default candidate providers for the scene.
  33932. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33933. * and getCollidingSubMeshCandidates to their default function
  33934. */
  33935. setDefaultCandidateProviders(): void;
  33936. /**
  33937. * Gets the mesh that is currently under the pointer
  33938. */
  33939. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33940. /**
  33941. * Gets or sets the current on-screen X position of the pointer
  33942. */
  33943. pointerX: number;
  33944. /**
  33945. * Gets or sets the current on-screen Y position of the pointer
  33946. */
  33947. pointerY: number;
  33948. /**
  33949. * Gets the cached material (ie. the latest rendered one)
  33950. * @returns the cached material
  33951. */
  33952. getCachedMaterial(): Nullable<Material>;
  33953. /**
  33954. * Gets the cached effect (ie. the latest rendered one)
  33955. * @returns the cached effect
  33956. */
  33957. getCachedEffect(): Nullable<Effect>;
  33958. /**
  33959. * Gets the cached visibility state (ie. the latest rendered one)
  33960. * @returns the cached visibility state
  33961. */
  33962. getCachedVisibility(): Nullable<number>;
  33963. /**
  33964. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33965. * @param material defines the current material
  33966. * @param effect defines the current effect
  33967. * @param visibility defines the current visibility state
  33968. * @returns true if one parameter is not cached
  33969. */
  33970. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33971. /**
  33972. * Gets the engine associated with the scene
  33973. * @returns an Engine
  33974. */
  33975. getEngine(): Engine;
  33976. /**
  33977. * Gets the total number of vertices rendered per frame
  33978. * @returns the total number of vertices rendered per frame
  33979. */
  33980. getTotalVertices(): number;
  33981. /**
  33982. * Gets the performance counter for total vertices
  33983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33984. */
  33985. readonly totalVerticesPerfCounter: PerfCounter;
  33986. /**
  33987. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33988. * @returns the total number of active indices rendered per frame
  33989. */
  33990. getActiveIndices(): number;
  33991. /**
  33992. * Gets the performance counter for active indices
  33993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33994. */
  33995. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33996. /**
  33997. * Gets the total number of active particles rendered per frame
  33998. * @returns the total number of active particles rendered per frame
  33999. */
  34000. getActiveParticles(): number;
  34001. /**
  34002. * Gets the performance counter for active particles
  34003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34004. */
  34005. readonly activeParticlesPerfCounter: PerfCounter;
  34006. /**
  34007. * Gets the total number of active bones rendered per frame
  34008. * @returns the total number of active bones rendered per frame
  34009. */
  34010. getActiveBones(): number;
  34011. /**
  34012. * Gets the performance counter for active bones
  34013. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34014. */
  34015. readonly activeBonesPerfCounter: PerfCounter;
  34016. /**
  34017. * Gets the array of active meshes
  34018. * @returns an array of AbstractMesh
  34019. */
  34020. getActiveMeshes(): SmartArray<AbstractMesh>;
  34021. /**
  34022. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34023. * @returns a number
  34024. */
  34025. getAnimationRatio(): number;
  34026. /**
  34027. * Gets an unique Id for the current render phase
  34028. * @returns a number
  34029. */
  34030. getRenderId(): number;
  34031. /**
  34032. * Gets an unique Id for the current frame
  34033. * @returns a number
  34034. */
  34035. getFrameId(): number;
  34036. /** Call this function if you want to manually increment the render Id*/
  34037. incrementRenderId(): void;
  34038. private _createUbo;
  34039. /**
  34040. * Use this method to simulate a pointer move on a mesh
  34041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34044. * @returns the current scene
  34045. */
  34046. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34047. /**
  34048. * Use this method to simulate a pointer down on a mesh
  34049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34052. * @returns the current scene
  34053. */
  34054. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34055. /**
  34056. * Use this method to simulate a pointer up on a mesh
  34057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34060. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34061. * @returns the current scene
  34062. */
  34063. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34064. /**
  34065. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34066. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34067. * @returns true if the pointer was captured
  34068. */
  34069. isPointerCaptured(pointerId?: number): boolean;
  34070. /**
  34071. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34072. * @param attachUp defines if you want to attach events to pointerup
  34073. * @param attachDown defines if you want to attach events to pointerdown
  34074. * @param attachMove defines if you want to attach events to pointermove
  34075. */
  34076. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34077. /** Detaches all event handlers*/
  34078. detachControl(): void;
  34079. /**
  34080. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34081. * Delay loaded resources are not taking in account
  34082. * @return true if all required resources are ready
  34083. */
  34084. isReady(): boolean;
  34085. /** Resets all cached information relative to material (including effect and visibility) */
  34086. resetCachedMaterial(): void;
  34087. /**
  34088. * Registers a function to be called before every frame render
  34089. * @param func defines the function to register
  34090. */
  34091. registerBeforeRender(func: () => void): void;
  34092. /**
  34093. * Unregisters a function called before every frame render
  34094. * @param func defines the function to unregister
  34095. */
  34096. unregisterBeforeRender(func: () => void): void;
  34097. /**
  34098. * Registers a function to be called after every frame render
  34099. * @param func defines the function to register
  34100. */
  34101. registerAfterRender(func: () => void): void;
  34102. /**
  34103. * Unregisters a function called after every frame render
  34104. * @param func defines the function to unregister
  34105. */
  34106. unregisterAfterRender(func: () => void): void;
  34107. private _executeOnceBeforeRender;
  34108. /**
  34109. * The provided function will run before render once and will be disposed afterwards.
  34110. * A timeout delay can be provided so that the function will be executed in N ms.
  34111. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34112. * @param func The function to be executed.
  34113. * @param timeout optional delay in ms
  34114. */
  34115. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34116. /** @hidden */
  34117. _addPendingData(data: any): void;
  34118. /** @hidden */
  34119. _removePendingData(data: any): void;
  34120. /**
  34121. * Returns the number of items waiting to be loaded
  34122. * @returns the number of items waiting to be loaded
  34123. */
  34124. getWaitingItemsCount(): number;
  34125. /**
  34126. * Returns a boolean indicating if the scene is still loading data
  34127. */
  34128. readonly isLoading: boolean;
  34129. /**
  34130. * Registers a function to be executed when the scene is ready
  34131. * @param {Function} func - the function to be executed
  34132. */
  34133. executeWhenReady(func: () => void): void;
  34134. /**
  34135. * Returns a promise that resolves when the scene is ready
  34136. * @returns A promise that resolves when the scene is ready
  34137. */
  34138. whenReadyAsync(): Promise<void>;
  34139. /** @hidden */
  34140. _checkIsReady(): void;
  34141. /**
  34142. * Gets all animatable attached to the scene
  34143. */
  34144. readonly animatables: Animatable[];
  34145. /**
  34146. * Resets the last animation time frame.
  34147. * Useful to override when animations start running when loading a scene for the first time.
  34148. */
  34149. resetLastAnimationTimeFrame(): void;
  34150. /**
  34151. * Gets the current view matrix
  34152. * @returns a Matrix
  34153. */
  34154. getViewMatrix(): Matrix;
  34155. /**
  34156. * Gets the current projection matrix
  34157. * @returns a Matrix
  34158. */
  34159. getProjectionMatrix(): Matrix;
  34160. /**
  34161. * Gets the current transform matrix
  34162. * @returns a Matrix made of View * Projection
  34163. */
  34164. getTransformMatrix(): Matrix;
  34165. /**
  34166. * Sets the current transform matrix
  34167. * @param viewL defines the View matrix to use
  34168. * @param projectionL defines the Projection matrix to use
  34169. * @param viewR defines the right View matrix to use (if provided)
  34170. * @param projectionR defines the right Projection matrix to use (if provided)
  34171. */
  34172. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34173. /**
  34174. * Gets the uniform buffer used to store scene data
  34175. * @returns a UniformBuffer
  34176. */
  34177. getSceneUniformBuffer(): UniformBuffer;
  34178. /**
  34179. * Gets an unique (relatively to the current scene) Id
  34180. * @returns an unique number for the scene
  34181. */
  34182. getUniqueId(): number;
  34183. /**
  34184. * Add a mesh to the list of scene's meshes
  34185. * @param newMesh defines the mesh to add
  34186. * @param recursive if all child meshes should also be added to the scene
  34187. */
  34188. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34189. /**
  34190. * Remove a mesh for the list of scene's meshes
  34191. * @param toRemove defines the mesh to remove
  34192. * @param recursive if all child meshes should also be removed from the scene
  34193. * @returns the index where the mesh was in the mesh list
  34194. */
  34195. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34196. /**
  34197. * Add a transform node to the list of scene's transform nodes
  34198. * @param newTransformNode defines the transform node to add
  34199. */
  34200. addTransformNode(newTransformNode: TransformNode): void;
  34201. /**
  34202. * Remove a transform node for the list of scene's transform nodes
  34203. * @param toRemove defines the transform node to remove
  34204. * @returns the index where the transform node was in the transform node list
  34205. */
  34206. removeTransformNode(toRemove: TransformNode): number;
  34207. /**
  34208. * Remove a skeleton for the list of scene's skeletons
  34209. * @param toRemove defines the skeleton to remove
  34210. * @returns the index where the skeleton was in the skeleton list
  34211. */
  34212. removeSkeleton(toRemove: Skeleton): number;
  34213. /**
  34214. * Remove a morph target for the list of scene's morph targets
  34215. * @param toRemove defines the morph target to remove
  34216. * @returns the index where the morph target was in the morph target list
  34217. */
  34218. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34219. /**
  34220. * Remove a light for the list of scene's lights
  34221. * @param toRemove defines the light to remove
  34222. * @returns the index where the light was in the light list
  34223. */
  34224. removeLight(toRemove: Light): number;
  34225. /**
  34226. * Remove a camera for the list of scene's cameras
  34227. * @param toRemove defines the camera to remove
  34228. * @returns the index where the camera was in the camera list
  34229. */
  34230. removeCamera(toRemove: Camera): number;
  34231. /**
  34232. * Remove a particle system for the list of scene's particle systems
  34233. * @param toRemove defines the particle system to remove
  34234. * @returns the index where the particle system was in the particle system list
  34235. */
  34236. removeParticleSystem(toRemove: IParticleSystem): number;
  34237. /**
  34238. * Remove a animation for the list of scene's animations
  34239. * @param toRemove defines the animation to remove
  34240. * @returns the index where the animation was in the animation list
  34241. */
  34242. removeAnimation(toRemove: Animation): number;
  34243. /**
  34244. * Will stop the animation of the given target
  34245. * @param target - the target
  34246. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34247. * @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)
  34248. */
  34249. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34250. /**
  34251. * Removes the given animation group from this scene.
  34252. * @param toRemove The animation group to remove
  34253. * @returns The index of the removed animation group
  34254. */
  34255. removeAnimationGroup(toRemove: AnimationGroup): number;
  34256. /**
  34257. * Removes the given multi-material from this scene.
  34258. * @param toRemove The multi-material to remove
  34259. * @returns The index of the removed multi-material
  34260. */
  34261. removeMultiMaterial(toRemove: MultiMaterial): number;
  34262. /**
  34263. * Removes the given material from this scene.
  34264. * @param toRemove The material to remove
  34265. * @returns The index of the removed material
  34266. */
  34267. removeMaterial(toRemove: Material): number;
  34268. /**
  34269. * Removes the given action manager from this scene.
  34270. * @param toRemove The action manager to remove
  34271. * @returns The index of the removed action manager
  34272. */
  34273. removeActionManager(toRemove: AbstractActionManager): number;
  34274. /**
  34275. * Removes the given texture from this scene.
  34276. * @param toRemove The texture to remove
  34277. * @returns The index of the removed texture
  34278. */
  34279. removeTexture(toRemove: BaseTexture): number;
  34280. /**
  34281. * Adds the given light to this scene
  34282. * @param newLight The light to add
  34283. */
  34284. addLight(newLight: Light): void;
  34285. /**
  34286. * Sorts the list list based on light priorities
  34287. */
  34288. sortLightsByPriority(): void;
  34289. /**
  34290. * Adds the given camera to this scene
  34291. * @param newCamera The camera to add
  34292. */
  34293. addCamera(newCamera: Camera): void;
  34294. /**
  34295. * Adds the given skeleton to this scene
  34296. * @param newSkeleton The skeleton to add
  34297. */
  34298. addSkeleton(newSkeleton: Skeleton): void;
  34299. /**
  34300. * Adds the given particle system to this scene
  34301. * @param newParticleSystem The particle system to add
  34302. */
  34303. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34304. /**
  34305. * Adds the given animation to this scene
  34306. * @param newAnimation The animation to add
  34307. */
  34308. addAnimation(newAnimation: Animation): void;
  34309. /**
  34310. * Adds the given animation group to this scene.
  34311. * @param newAnimationGroup The animation group to add
  34312. */
  34313. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34314. /**
  34315. * Adds the given multi-material to this scene
  34316. * @param newMultiMaterial The multi-material to add
  34317. */
  34318. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34319. /**
  34320. * Adds the given material to this scene
  34321. * @param newMaterial The material to add
  34322. */
  34323. addMaterial(newMaterial: Material): void;
  34324. /**
  34325. * Adds the given morph target to this scene
  34326. * @param newMorphTargetManager The morph target to add
  34327. */
  34328. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34329. /**
  34330. * Adds the given geometry to this scene
  34331. * @param newGeometry The geometry to add
  34332. */
  34333. addGeometry(newGeometry: Geometry): void;
  34334. /**
  34335. * Adds the given action manager to this scene
  34336. * @param newActionManager The action manager to add
  34337. */
  34338. addActionManager(newActionManager: AbstractActionManager): void;
  34339. /**
  34340. * Adds the given texture to this scene.
  34341. * @param newTexture The texture to add
  34342. */
  34343. addTexture(newTexture: BaseTexture): void;
  34344. /**
  34345. * Switch active camera
  34346. * @param newCamera defines the new active camera
  34347. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34348. */
  34349. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34350. /**
  34351. * sets the active camera of the scene using its ID
  34352. * @param id defines the camera's ID
  34353. * @return the new active camera or null if none found.
  34354. */
  34355. setActiveCameraByID(id: string): Nullable<Camera>;
  34356. /**
  34357. * sets the active camera of the scene using its name
  34358. * @param name defines the camera's name
  34359. * @returns the new active camera or null if none found.
  34360. */
  34361. setActiveCameraByName(name: string): Nullable<Camera>;
  34362. /**
  34363. * get an animation group using its name
  34364. * @param name defines the material's name
  34365. * @return the animation group or null if none found.
  34366. */
  34367. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34368. /**
  34369. * Get a material using its unique id
  34370. * @param uniqueId defines the material's unique id
  34371. * @return the material or null if none found.
  34372. */
  34373. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34374. /**
  34375. * get a material using its id
  34376. * @param id defines the material's ID
  34377. * @return the material or null if none found.
  34378. */
  34379. getMaterialByID(id: string): Nullable<Material>;
  34380. /**
  34381. * Gets a the last added material using a given id
  34382. * @param id defines the material's ID
  34383. * @return the last material with the given id or null if none found.
  34384. */
  34385. getLastMaterialByID(id: string): Nullable<Material>;
  34386. /**
  34387. * Gets a material using its name
  34388. * @param name defines the material's name
  34389. * @return the material or null if none found.
  34390. */
  34391. getMaterialByName(name: string): Nullable<Material>;
  34392. /**
  34393. * Get a texture using its unique id
  34394. * @param uniqueId defines the texture's unique id
  34395. * @return the texture or null if none found.
  34396. */
  34397. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34398. /**
  34399. * Gets a camera using its id
  34400. * @param id defines the id to look for
  34401. * @returns the camera or null if not found
  34402. */
  34403. getCameraByID(id: string): Nullable<Camera>;
  34404. /**
  34405. * Gets a camera using its unique id
  34406. * @param uniqueId defines the unique id to look for
  34407. * @returns the camera or null if not found
  34408. */
  34409. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34410. /**
  34411. * Gets a camera using its name
  34412. * @param name defines the camera's name
  34413. * @return the camera or null if none found.
  34414. */
  34415. getCameraByName(name: string): Nullable<Camera>;
  34416. /**
  34417. * Gets a bone using its id
  34418. * @param id defines the bone's id
  34419. * @return the bone or null if not found
  34420. */
  34421. getBoneByID(id: string): Nullable<Bone>;
  34422. /**
  34423. * Gets a bone using its id
  34424. * @param name defines the bone's name
  34425. * @return the bone or null if not found
  34426. */
  34427. getBoneByName(name: string): Nullable<Bone>;
  34428. /**
  34429. * Gets a light node using its name
  34430. * @param name defines the the light's name
  34431. * @return the light or null if none found.
  34432. */
  34433. getLightByName(name: string): Nullable<Light>;
  34434. /**
  34435. * Gets a light node using its id
  34436. * @param id defines the light's id
  34437. * @return the light or null if none found.
  34438. */
  34439. getLightByID(id: string): Nullable<Light>;
  34440. /**
  34441. * Gets a light node using its scene-generated unique ID
  34442. * @param uniqueId defines the light's unique id
  34443. * @return the light or null if none found.
  34444. */
  34445. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34446. /**
  34447. * Gets a particle system by id
  34448. * @param id defines the particle system id
  34449. * @return the corresponding system or null if none found
  34450. */
  34451. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34452. /**
  34453. * Gets a geometry using its ID
  34454. * @param id defines the geometry's id
  34455. * @return the geometry or null if none found.
  34456. */
  34457. getGeometryByID(id: string): Nullable<Geometry>;
  34458. private _getGeometryByUniqueID;
  34459. /**
  34460. * Add a new geometry to this scene
  34461. * @param geometry defines the geometry to be added to the scene.
  34462. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34463. * @return a boolean defining if the geometry was added or not
  34464. */
  34465. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34466. /**
  34467. * Removes an existing geometry
  34468. * @param geometry defines the geometry to be removed from the scene
  34469. * @return a boolean defining if the geometry was removed or not
  34470. */
  34471. removeGeometry(geometry: Geometry): boolean;
  34472. /**
  34473. * Gets the list of geometries attached to the scene
  34474. * @returns an array of Geometry
  34475. */
  34476. getGeometries(): Geometry[];
  34477. /**
  34478. * Gets the first added mesh found of a given ID
  34479. * @param id defines the id to search for
  34480. * @return the mesh found or null if not found at all
  34481. */
  34482. getMeshByID(id: string): Nullable<AbstractMesh>;
  34483. /**
  34484. * Gets a list of meshes using their id
  34485. * @param id defines the id to search for
  34486. * @returns a list of meshes
  34487. */
  34488. getMeshesByID(id: string): Array<AbstractMesh>;
  34489. /**
  34490. * Gets the first added transform node found of a given ID
  34491. * @param id defines the id to search for
  34492. * @return the found transform node or null if not found at all.
  34493. */
  34494. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34495. /**
  34496. * Gets a transform node with its auto-generated unique id
  34497. * @param uniqueId efines the unique id to search for
  34498. * @return the found transform node or null if not found at all.
  34499. */
  34500. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34501. /**
  34502. * Gets a list of transform nodes using their id
  34503. * @param id defines the id to search for
  34504. * @returns a list of transform nodes
  34505. */
  34506. getTransformNodesByID(id: string): Array<TransformNode>;
  34507. /**
  34508. * Gets a mesh with its auto-generated unique id
  34509. * @param uniqueId defines the unique id to search for
  34510. * @return the found mesh or null if not found at all.
  34511. */
  34512. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34513. /**
  34514. * Gets a the last added mesh using a given id
  34515. * @param id defines the id to search for
  34516. * @return the found mesh or null if not found at all.
  34517. */
  34518. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34519. /**
  34520. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34521. * @param id defines the id to search for
  34522. * @return the found node or null if not found at all
  34523. */
  34524. getLastEntryByID(id: string): Nullable<Node>;
  34525. /**
  34526. * Gets a node (Mesh, Camera, Light) using a given id
  34527. * @param id defines the id to search for
  34528. * @return the found node or null if not found at all
  34529. */
  34530. getNodeByID(id: string): Nullable<Node>;
  34531. /**
  34532. * Gets a node (Mesh, Camera, Light) using a given name
  34533. * @param name defines the name to search for
  34534. * @return the found node or null if not found at all.
  34535. */
  34536. getNodeByName(name: string): Nullable<Node>;
  34537. /**
  34538. * Gets a mesh using a given name
  34539. * @param name defines the name to search for
  34540. * @return the found mesh or null if not found at all.
  34541. */
  34542. getMeshByName(name: string): Nullable<AbstractMesh>;
  34543. /**
  34544. * Gets a transform node using a given name
  34545. * @param name defines the name to search for
  34546. * @return the found transform node or null if not found at all.
  34547. */
  34548. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34549. /**
  34550. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34551. * @param id defines the id to search for
  34552. * @return the found skeleton or null if not found at all.
  34553. */
  34554. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34555. /**
  34556. * Gets a skeleton using a given auto generated unique id
  34557. * @param uniqueId defines the unique id to search for
  34558. * @return the found skeleton or null if not found at all.
  34559. */
  34560. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34561. /**
  34562. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34563. * @param id defines the id to search for
  34564. * @return the found skeleton or null if not found at all.
  34565. */
  34566. getSkeletonById(id: string): Nullable<Skeleton>;
  34567. /**
  34568. * Gets a skeleton using a given name
  34569. * @param name defines the name to search for
  34570. * @return the found skeleton or null if not found at all.
  34571. */
  34572. getSkeletonByName(name: string): Nullable<Skeleton>;
  34573. /**
  34574. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34575. * @param id defines the id to search for
  34576. * @return the found morph target manager or null if not found at all.
  34577. */
  34578. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34579. /**
  34580. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34581. * @param id defines the id to search for
  34582. * @return the found morph target or null if not found at all.
  34583. */
  34584. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34585. /**
  34586. * Gets a boolean indicating if the given mesh is active
  34587. * @param mesh defines the mesh to look for
  34588. * @returns true if the mesh is in the active list
  34589. */
  34590. isActiveMesh(mesh: AbstractMesh): boolean;
  34591. /**
  34592. * Return a unique id as a string which can serve as an identifier for the scene
  34593. */
  34594. readonly uid: string;
  34595. /**
  34596. * Add an externaly attached data from its key.
  34597. * This method call will fail and return false, if such key already exists.
  34598. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34599. * @param key the unique key that identifies the data
  34600. * @param data the data object to associate to the key for this Engine instance
  34601. * @return true if no such key were already present and the data was added successfully, false otherwise
  34602. */
  34603. addExternalData<T>(key: string, data: T): boolean;
  34604. /**
  34605. * Get an externaly attached data from its key
  34606. * @param key the unique key that identifies the data
  34607. * @return the associated data, if present (can be null), or undefined if not present
  34608. */
  34609. getExternalData<T>(key: string): Nullable<T>;
  34610. /**
  34611. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34612. * @param key the unique key that identifies the data
  34613. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34614. * @return the associated data, can be null if the factory returned null.
  34615. */
  34616. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34617. /**
  34618. * Remove an externaly attached data from the Engine instance
  34619. * @param key the unique key that identifies the data
  34620. * @return true if the data was successfully removed, false if it doesn't exist
  34621. */
  34622. removeExternalData(key: string): boolean;
  34623. private _evaluateSubMesh;
  34624. /**
  34625. * Clear the processed materials smart array preventing retention point in material dispose.
  34626. */
  34627. freeProcessedMaterials(): void;
  34628. private _preventFreeActiveMeshesAndRenderingGroups;
  34629. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34630. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34631. * when disposing several meshes in a row or a hierarchy of meshes.
  34632. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34633. */
  34634. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34635. /**
  34636. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34637. */
  34638. freeActiveMeshes(): void;
  34639. /**
  34640. * Clear the info related to rendering groups preventing retention points during dispose.
  34641. */
  34642. freeRenderingGroups(): void;
  34643. /** @hidden */
  34644. _isInIntermediateRendering(): boolean;
  34645. /**
  34646. * Lambda returning the list of potentially active meshes.
  34647. */
  34648. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34649. /**
  34650. * Lambda returning the list of potentially active sub meshes.
  34651. */
  34652. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34653. /**
  34654. * Lambda returning the list of potentially intersecting sub meshes.
  34655. */
  34656. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34657. /**
  34658. * Lambda returning the list of potentially colliding sub meshes.
  34659. */
  34660. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34661. private _activeMeshesFrozen;
  34662. /**
  34663. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34664. * @returns the current scene
  34665. */
  34666. freezeActiveMeshes(): Scene;
  34667. /**
  34668. * Use this function to restart evaluating active meshes on every frame
  34669. * @returns the current scene
  34670. */
  34671. unfreezeActiveMeshes(): Scene;
  34672. private _evaluateActiveMeshes;
  34673. private _activeMesh;
  34674. /**
  34675. * Update the transform matrix to update from the current active camera
  34676. * @param force defines a boolean used to force the update even if cache is up to date
  34677. */
  34678. updateTransformMatrix(force?: boolean): void;
  34679. private _bindFrameBuffer;
  34680. /** @hidden */
  34681. _allowPostProcessClearColor: boolean;
  34682. /** @hidden */
  34683. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34684. private _processSubCameras;
  34685. private _checkIntersections;
  34686. /** @hidden */
  34687. _advancePhysicsEngineStep(step: number): void;
  34688. /**
  34689. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34690. */
  34691. getDeterministicFrameTime: () => number;
  34692. /** @hidden */
  34693. _animate(): void;
  34694. /** Execute all animations (for a frame) */
  34695. animate(): void;
  34696. /**
  34697. * Render the scene
  34698. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34699. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34700. */
  34701. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34702. /**
  34703. * Freeze all materials
  34704. * A frozen material will not be updatable but should be faster to render
  34705. */
  34706. freezeMaterials(): void;
  34707. /**
  34708. * Unfreeze all materials
  34709. * A frozen material will not be updatable but should be faster to render
  34710. */
  34711. unfreezeMaterials(): void;
  34712. /**
  34713. * Releases all held ressources
  34714. */
  34715. dispose(): void;
  34716. /**
  34717. * Gets if the scene is already disposed
  34718. */
  34719. readonly isDisposed: boolean;
  34720. /**
  34721. * Call this function to reduce memory footprint of the scene.
  34722. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34723. */
  34724. clearCachedVertexData(): void;
  34725. /**
  34726. * This function will remove the local cached buffer data from texture.
  34727. * It will save memory but will prevent the texture from being rebuilt
  34728. */
  34729. cleanCachedTextureBuffer(): void;
  34730. /**
  34731. * Get the world extend vectors with an optional filter
  34732. *
  34733. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34734. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34735. */
  34736. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34737. min: Vector3;
  34738. max: Vector3;
  34739. };
  34740. /**
  34741. * Creates a ray that can be used to pick in the scene
  34742. * @param x defines the x coordinate of the origin (on-screen)
  34743. * @param y defines the y coordinate of the origin (on-screen)
  34744. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34745. * @param camera defines the camera to use for the picking
  34746. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34747. * @returns a Ray
  34748. */
  34749. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34750. /**
  34751. * Creates a ray that can be used to pick in the scene
  34752. * @param x defines the x coordinate of the origin (on-screen)
  34753. * @param y defines the y coordinate of the origin (on-screen)
  34754. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34755. * @param result defines the ray where to store the picking ray
  34756. * @param camera defines the camera to use for the picking
  34757. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34758. * @returns the current scene
  34759. */
  34760. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34761. /**
  34762. * Creates a ray that can be used to pick in the scene
  34763. * @param x defines the x coordinate of the origin (on-screen)
  34764. * @param y defines the y coordinate of the origin (on-screen)
  34765. * @param camera defines the camera to use for the picking
  34766. * @returns a Ray
  34767. */
  34768. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34769. /**
  34770. * Creates a ray that can be used to pick in the scene
  34771. * @param x defines the x coordinate of the origin (on-screen)
  34772. * @param y defines the y coordinate of the origin (on-screen)
  34773. * @param result defines the ray where to store the picking ray
  34774. * @param camera defines the camera to use for the picking
  34775. * @returns the current scene
  34776. */
  34777. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34778. /** Launch a ray to try to pick a mesh in the scene
  34779. * @param x position on screen
  34780. * @param y position on screen
  34781. * @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
  34782. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34783. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34784. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34785. * @returns a PickingInfo
  34786. */
  34787. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34788. /** Use the given ray to pick a mesh in the scene
  34789. * @param ray The ray to use to pick meshes
  34790. * @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
  34791. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34792. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34793. * @returns a PickingInfo
  34794. */
  34795. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34796. /**
  34797. * Launch a ray to try to pick a mesh in the scene
  34798. * @param x X position on screen
  34799. * @param y Y position on screen
  34800. * @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
  34801. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34802. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34803. * @returns an array of PickingInfo
  34804. */
  34805. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34806. /**
  34807. * Launch a ray to try to pick a mesh in the scene
  34808. * @param ray Ray to use
  34809. * @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
  34810. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34811. * @returns an array of PickingInfo
  34812. */
  34813. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34814. /**
  34815. * Force the value of meshUnderPointer
  34816. * @param mesh defines the mesh to use
  34817. */
  34818. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34819. /**
  34820. * Gets the mesh under the pointer
  34821. * @returns a Mesh or null if no mesh is under the pointer
  34822. */
  34823. getPointerOverMesh(): Nullable<AbstractMesh>;
  34824. /** @hidden */
  34825. _rebuildGeometries(): void;
  34826. /** @hidden */
  34827. _rebuildTextures(): void;
  34828. private _getByTags;
  34829. /**
  34830. * Get a list of meshes by tags
  34831. * @param tagsQuery defines the tags query to use
  34832. * @param forEach defines a predicate used to filter results
  34833. * @returns an array of Mesh
  34834. */
  34835. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34836. /**
  34837. * Get a list of cameras by tags
  34838. * @param tagsQuery defines the tags query to use
  34839. * @param forEach defines a predicate used to filter results
  34840. * @returns an array of Camera
  34841. */
  34842. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34843. /**
  34844. * Get a list of lights by tags
  34845. * @param tagsQuery defines the tags query to use
  34846. * @param forEach defines a predicate used to filter results
  34847. * @returns an array of Light
  34848. */
  34849. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34850. /**
  34851. * Get a list of materials by tags
  34852. * @param tagsQuery defines the tags query to use
  34853. * @param forEach defines a predicate used to filter results
  34854. * @returns an array of Material
  34855. */
  34856. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34857. /**
  34858. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34859. * This allowed control for front to back rendering or reversly depending of the special needs.
  34860. *
  34861. * @param renderingGroupId The rendering group id corresponding to its index
  34862. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34863. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34864. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34865. */
  34866. 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;
  34867. /**
  34868. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34869. *
  34870. * @param renderingGroupId The rendering group id corresponding to its index
  34871. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34872. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34873. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34874. */
  34875. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34876. /**
  34877. * Gets the current auto clear configuration for one rendering group of the rendering
  34878. * manager.
  34879. * @param index the rendering group index to get the information for
  34880. * @returns The auto clear setup for the requested rendering group
  34881. */
  34882. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34883. private _blockMaterialDirtyMechanism;
  34884. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34885. blockMaterialDirtyMechanism: boolean;
  34886. /**
  34887. * Will flag all materials as dirty to trigger new shader compilation
  34888. * @param flag defines the flag used to specify which material part must be marked as dirty
  34889. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34890. */
  34891. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34892. /** @hidden */
  34893. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34894. /** @hidden */
  34895. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34896. /** @hidden */
  34897. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  34898. /** @hidden */
  34899. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34900. /** @hidden */
  34901. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34902. /** @hidden */
  34903. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34904. }
  34905. }
  34906. declare module BABYLON {
  34907. /**
  34908. * Set of assets to keep when moving a scene into an asset container.
  34909. */
  34910. export class KeepAssets extends AbstractScene {
  34911. }
  34912. /**
  34913. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  34914. */
  34915. export class InstantiatedEntries {
  34916. /**
  34917. * List of new root nodes (eg. nodes with no parent)
  34918. */
  34919. rootNodes: TransformNode[];
  34920. /**
  34921. * List of new skeletons
  34922. */
  34923. skeletons: Skeleton[];
  34924. /**
  34925. * List of new animation groups
  34926. */
  34927. animationGroups: AnimationGroup[];
  34928. }
  34929. /**
  34930. * Container with a set of assets that can be added or removed from a scene.
  34931. */
  34932. export class AssetContainer extends AbstractScene {
  34933. /**
  34934. * The scene the AssetContainer belongs to.
  34935. */
  34936. scene: Scene;
  34937. /**
  34938. * Instantiates an AssetContainer.
  34939. * @param scene The scene the AssetContainer belongs to.
  34940. */
  34941. constructor(scene: Scene);
  34942. /**
  34943. * Instantiate or clone all meshes and add the new ones to the scene.
  34944. * Skeletons and animation groups will all be cloned
  34945. * @param nameFunction defines an optional function used to get new names for clones
  34946. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  34947. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  34948. */
  34949. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  34950. /**
  34951. * Adds all the assets from the container to the scene.
  34952. */
  34953. addAllToScene(): void;
  34954. /**
  34955. * Removes all the assets in the container from the scene
  34956. */
  34957. removeAllFromScene(): void;
  34958. /**
  34959. * Disposes all the assets in the container
  34960. */
  34961. dispose(): void;
  34962. private _moveAssets;
  34963. /**
  34964. * Removes all the assets contained in the scene and adds them to the container.
  34965. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34966. */
  34967. moveAllFromScene(keepAssets?: KeepAssets): void;
  34968. /**
  34969. * 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.
  34970. * @returns the root mesh
  34971. */
  34972. createRootMesh(): Mesh;
  34973. }
  34974. }
  34975. declare module BABYLON {
  34976. /**
  34977. * Defines how the parser contract is defined.
  34978. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34979. */
  34980. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34981. /**
  34982. * Defines how the individual parser contract is defined.
  34983. * These parser can parse an individual asset
  34984. */
  34985. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34986. /**
  34987. * Base class of the scene acting as a container for the different elements composing a scene.
  34988. * This class is dynamically extended by the different components of the scene increasing
  34989. * flexibility and reducing coupling
  34990. */
  34991. export abstract class AbstractScene {
  34992. /**
  34993. * Stores the list of available parsers in the application.
  34994. */
  34995. private static _BabylonFileParsers;
  34996. /**
  34997. * Stores the list of available individual parsers in the application.
  34998. */
  34999. private static _IndividualBabylonFileParsers;
  35000. /**
  35001. * Adds a parser in the list of available ones
  35002. * @param name Defines the name of the parser
  35003. * @param parser Defines the parser to add
  35004. */
  35005. static AddParser(name: string, parser: BabylonFileParser): void;
  35006. /**
  35007. * Gets a general parser from the list of avaialble ones
  35008. * @param name Defines the name of the parser
  35009. * @returns the requested parser or null
  35010. */
  35011. static GetParser(name: string): Nullable<BabylonFileParser>;
  35012. /**
  35013. * Adds n individual parser in the list of available ones
  35014. * @param name Defines the name of the parser
  35015. * @param parser Defines the parser to add
  35016. */
  35017. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35018. /**
  35019. * Gets an individual parser from the list of avaialble ones
  35020. * @param name Defines the name of the parser
  35021. * @returns the requested parser or null
  35022. */
  35023. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35024. /**
  35025. * Parser json data and populate both a scene and its associated container object
  35026. * @param jsonData Defines the data to parse
  35027. * @param scene Defines the scene to parse the data for
  35028. * @param container Defines the container attached to the parsing sequence
  35029. * @param rootUrl Defines the root url of the data
  35030. */
  35031. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35032. /**
  35033. * Gets the list of root nodes (ie. nodes with no parent)
  35034. */
  35035. rootNodes: Node[];
  35036. /** All of the cameras added to this scene
  35037. * @see http://doc.babylonjs.com/babylon101/cameras
  35038. */
  35039. cameras: Camera[];
  35040. /**
  35041. * All of the lights added to this scene
  35042. * @see http://doc.babylonjs.com/babylon101/lights
  35043. */
  35044. lights: Light[];
  35045. /**
  35046. * All of the (abstract) meshes added to this scene
  35047. */
  35048. meshes: AbstractMesh[];
  35049. /**
  35050. * The list of skeletons added to the scene
  35051. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35052. */
  35053. skeletons: Skeleton[];
  35054. /**
  35055. * All of the particle systems added to this scene
  35056. * @see http://doc.babylonjs.com/babylon101/particles
  35057. */
  35058. particleSystems: IParticleSystem[];
  35059. /**
  35060. * Gets a list of Animations associated with the scene
  35061. */
  35062. animations: Animation[];
  35063. /**
  35064. * All of the animation groups added to this scene
  35065. * @see http://doc.babylonjs.com/how_to/group
  35066. */
  35067. animationGroups: AnimationGroup[];
  35068. /**
  35069. * All of the multi-materials added to this scene
  35070. * @see http://doc.babylonjs.com/how_to/multi_materials
  35071. */
  35072. multiMaterials: MultiMaterial[];
  35073. /**
  35074. * All of the materials added to this scene
  35075. * In the context of a Scene, it is not supposed to be modified manually.
  35076. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35077. * Note also that the order of the Material within the array is not significant and might change.
  35078. * @see http://doc.babylonjs.com/babylon101/materials
  35079. */
  35080. materials: Material[];
  35081. /**
  35082. * The list of morph target managers added to the scene
  35083. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35084. */
  35085. morphTargetManagers: MorphTargetManager[];
  35086. /**
  35087. * The list of geometries used in the scene.
  35088. */
  35089. geometries: Geometry[];
  35090. /**
  35091. * All of the tranform nodes added to this scene
  35092. * In the context of a Scene, it is not supposed to be modified manually.
  35093. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35094. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35095. * @see http://doc.babylonjs.com/how_to/transformnode
  35096. */
  35097. transformNodes: TransformNode[];
  35098. /**
  35099. * ActionManagers available on the scene.
  35100. */
  35101. actionManagers: AbstractActionManager[];
  35102. /**
  35103. * Textures to keep.
  35104. */
  35105. textures: BaseTexture[];
  35106. /**
  35107. * Environment texture for the scene
  35108. */
  35109. environmentTexture: Nullable<BaseTexture>;
  35110. }
  35111. }
  35112. declare module BABYLON {
  35113. /**
  35114. * Interface used to define options for Sound class
  35115. */
  35116. export interface ISoundOptions {
  35117. /**
  35118. * Does the sound autoplay once loaded.
  35119. */
  35120. autoplay?: boolean;
  35121. /**
  35122. * Does the sound loop after it finishes playing once.
  35123. */
  35124. loop?: boolean;
  35125. /**
  35126. * Sound's volume
  35127. */
  35128. volume?: number;
  35129. /**
  35130. * Is it a spatial sound?
  35131. */
  35132. spatialSound?: boolean;
  35133. /**
  35134. * Maximum distance to hear that sound
  35135. */
  35136. maxDistance?: number;
  35137. /**
  35138. * Uses user defined attenuation function
  35139. */
  35140. useCustomAttenuation?: boolean;
  35141. /**
  35142. * Define the roll off factor of spatial sounds.
  35143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35144. */
  35145. rolloffFactor?: number;
  35146. /**
  35147. * Define the reference distance the sound should be heard perfectly.
  35148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35149. */
  35150. refDistance?: number;
  35151. /**
  35152. * Define the distance attenuation model the sound will follow.
  35153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35154. */
  35155. distanceModel?: string;
  35156. /**
  35157. * Defines the playback speed (1 by default)
  35158. */
  35159. playbackRate?: number;
  35160. /**
  35161. * Defines if the sound is from a streaming source
  35162. */
  35163. streaming?: boolean;
  35164. /**
  35165. * Defines an optional length (in seconds) inside the sound file
  35166. */
  35167. length?: number;
  35168. /**
  35169. * Defines an optional offset (in seconds) inside the sound file
  35170. */
  35171. offset?: number;
  35172. /**
  35173. * If true, URLs will not be required to state the audio file codec to use.
  35174. */
  35175. skipCodecCheck?: boolean;
  35176. }
  35177. /**
  35178. * Defines a sound that can be played in the application.
  35179. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35181. */
  35182. export class Sound {
  35183. /**
  35184. * The name of the sound in the scene.
  35185. */
  35186. name: string;
  35187. /**
  35188. * Does the sound autoplay once loaded.
  35189. */
  35190. autoplay: boolean;
  35191. /**
  35192. * Does the sound loop after it finishes playing once.
  35193. */
  35194. loop: boolean;
  35195. /**
  35196. * Does the sound use a custom attenuation curve to simulate the falloff
  35197. * happening when the source gets further away from the camera.
  35198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35199. */
  35200. useCustomAttenuation: boolean;
  35201. /**
  35202. * The sound track id this sound belongs to.
  35203. */
  35204. soundTrackId: number;
  35205. /**
  35206. * Is this sound currently played.
  35207. */
  35208. isPlaying: boolean;
  35209. /**
  35210. * Is this sound currently paused.
  35211. */
  35212. isPaused: boolean;
  35213. /**
  35214. * Does this sound enables spatial sound.
  35215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35216. */
  35217. spatialSound: boolean;
  35218. /**
  35219. * Define the reference distance the sound should be heard perfectly.
  35220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35221. */
  35222. refDistance: number;
  35223. /**
  35224. * Define the roll off factor of spatial sounds.
  35225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35226. */
  35227. rolloffFactor: number;
  35228. /**
  35229. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35231. */
  35232. maxDistance: number;
  35233. /**
  35234. * Define the distance attenuation model the sound will follow.
  35235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35236. */
  35237. distanceModel: string;
  35238. /**
  35239. * @hidden
  35240. * Back Compat
  35241. **/
  35242. onended: () => any;
  35243. /**
  35244. * Observable event when the current playing sound finishes.
  35245. */
  35246. onEndedObservable: Observable<Sound>;
  35247. private _panningModel;
  35248. private _playbackRate;
  35249. private _streaming;
  35250. private _startTime;
  35251. private _startOffset;
  35252. private _position;
  35253. /** @hidden */
  35254. _positionInEmitterSpace: boolean;
  35255. private _localDirection;
  35256. private _volume;
  35257. private _isReadyToPlay;
  35258. private _isDirectional;
  35259. private _readyToPlayCallback;
  35260. private _audioBuffer;
  35261. private _soundSource;
  35262. private _streamingSource;
  35263. private _soundPanner;
  35264. private _soundGain;
  35265. private _inputAudioNode;
  35266. private _outputAudioNode;
  35267. private _coneInnerAngle;
  35268. private _coneOuterAngle;
  35269. private _coneOuterGain;
  35270. private _scene;
  35271. private _connectedTransformNode;
  35272. private _customAttenuationFunction;
  35273. private _registerFunc;
  35274. private _isOutputConnected;
  35275. private _htmlAudioElement;
  35276. private _urlType;
  35277. private _length?;
  35278. private _offset?;
  35279. /** @hidden */
  35280. static _SceneComponentInitialization: (scene: Scene) => void;
  35281. /**
  35282. * Create a sound and attach it to a scene
  35283. * @param name Name of your sound
  35284. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35285. * @param scene defines the scene the sound belongs to
  35286. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35287. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35288. */
  35289. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35290. /**
  35291. * Release the sound and its associated resources
  35292. */
  35293. dispose(): void;
  35294. /**
  35295. * Gets if the sounds is ready to be played or not.
  35296. * @returns true if ready, otherwise false
  35297. */
  35298. isReady(): boolean;
  35299. private _soundLoaded;
  35300. /**
  35301. * Sets the data of the sound from an audiobuffer
  35302. * @param audioBuffer The audioBuffer containing the data
  35303. */
  35304. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35305. /**
  35306. * Updates the current sounds options such as maxdistance, loop...
  35307. * @param options A JSON object containing values named as the object properties
  35308. */
  35309. updateOptions(options: ISoundOptions): void;
  35310. private _createSpatialParameters;
  35311. private _updateSpatialParameters;
  35312. /**
  35313. * Switch the panning model to HRTF:
  35314. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35316. */
  35317. switchPanningModelToHRTF(): void;
  35318. /**
  35319. * Switch the panning model to Equal Power:
  35320. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35322. */
  35323. switchPanningModelToEqualPower(): void;
  35324. private _switchPanningModel;
  35325. /**
  35326. * Connect this sound to a sound track audio node like gain...
  35327. * @param soundTrackAudioNode the sound track audio node to connect to
  35328. */
  35329. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35330. /**
  35331. * Transform this sound into a directional source
  35332. * @param coneInnerAngle Size of the inner cone in degree
  35333. * @param coneOuterAngle Size of the outer cone in degree
  35334. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35335. */
  35336. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35337. /**
  35338. * Gets or sets the inner angle for the directional cone.
  35339. */
  35340. /**
  35341. * Gets or sets the inner angle for the directional cone.
  35342. */
  35343. directionalConeInnerAngle: number;
  35344. /**
  35345. * Gets or sets the outer angle for the directional cone.
  35346. */
  35347. /**
  35348. * Gets or sets the outer angle for the directional cone.
  35349. */
  35350. directionalConeOuterAngle: number;
  35351. /**
  35352. * Sets the position of the emitter if spatial sound is enabled
  35353. * @param newPosition Defines the new posisiton
  35354. */
  35355. setPosition(newPosition: Vector3): void;
  35356. /**
  35357. * Sets the local direction of the emitter if spatial sound is enabled
  35358. * @param newLocalDirection Defines the new local direction
  35359. */
  35360. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35361. private _updateDirection;
  35362. /** @hidden */
  35363. updateDistanceFromListener(): void;
  35364. /**
  35365. * Sets a new custom attenuation function for the sound.
  35366. * @param callback Defines the function used for the attenuation
  35367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35368. */
  35369. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35370. /**
  35371. * Play the sound
  35372. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35373. * @param offset (optional) Start the sound at a specific time in seconds
  35374. * @param length (optional) Sound duration (in seconds)
  35375. */
  35376. play(time?: number, offset?: number, length?: number): void;
  35377. private _onended;
  35378. /**
  35379. * Stop the sound
  35380. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35381. */
  35382. stop(time?: number): void;
  35383. /**
  35384. * Put the sound in pause
  35385. */
  35386. pause(): void;
  35387. /**
  35388. * Sets a dedicated volume for this sounds
  35389. * @param newVolume Define the new volume of the sound
  35390. * @param time Define time for gradual change to new volume
  35391. */
  35392. setVolume(newVolume: number, time?: number): void;
  35393. /**
  35394. * Set the sound play back rate
  35395. * @param newPlaybackRate Define the playback rate the sound should be played at
  35396. */
  35397. setPlaybackRate(newPlaybackRate: number): void;
  35398. /**
  35399. * Gets the volume of the sound.
  35400. * @returns the volume of the sound
  35401. */
  35402. getVolume(): number;
  35403. /**
  35404. * Attach the sound to a dedicated mesh
  35405. * @param transformNode The transform node to connect the sound with
  35406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35407. */
  35408. attachToMesh(transformNode: TransformNode): void;
  35409. /**
  35410. * Detach the sound from the previously attached mesh
  35411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35412. */
  35413. detachFromMesh(): void;
  35414. private _onRegisterAfterWorldMatrixUpdate;
  35415. /**
  35416. * Clone the current sound in the scene.
  35417. * @returns the new sound clone
  35418. */
  35419. clone(): Nullable<Sound>;
  35420. /**
  35421. * Gets the current underlying audio buffer containing the data
  35422. * @returns the audio buffer
  35423. */
  35424. getAudioBuffer(): Nullable<AudioBuffer>;
  35425. /**
  35426. * Serializes the Sound in a JSON representation
  35427. * @returns the JSON representation of the sound
  35428. */
  35429. serialize(): any;
  35430. /**
  35431. * Parse a JSON representation of a sound to innstantiate in a given scene
  35432. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35433. * @param scene Define the scene the new parsed sound should be created in
  35434. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35435. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35436. * @returns the newly parsed sound
  35437. */
  35438. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35439. }
  35440. }
  35441. declare module BABYLON {
  35442. /**
  35443. * This defines an action helpful to play a defined sound on a triggered action.
  35444. */
  35445. export class PlaySoundAction extends Action {
  35446. private _sound;
  35447. /**
  35448. * Instantiate the action
  35449. * @param triggerOptions defines the trigger options
  35450. * @param sound defines the sound to play
  35451. * @param condition defines the trigger related conditions
  35452. */
  35453. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35454. /** @hidden */
  35455. _prepare(): void;
  35456. /**
  35457. * Execute the action and play the sound.
  35458. */
  35459. execute(): void;
  35460. /**
  35461. * Serializes the actions and its related information.
  35462. * @param parent defines the object to serialize in
  35463. * @returns the serialized object
  35464. */
  35465. serialize(parent: any): any;
  35466. }
  35467. /**
  35468. * This defines an action helpful to stop a defined sound on a triggered action.
  35469. */
  35470. export class StopSoundAction extends Action {
  35471. private _sound;
  35472. /**
  35473. * Instantiate the action
  35474. * @param triggerOptions defines the trigger options
  35475. * @param sound defines the sound to stop
  35476. * @param condition defines the trigger related conditions
  35477. */
  35478. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35479. /** @hidden */
  35480. _prepare(): void;
  35481. /**
  35482. * Execute the action and stop the sound.
  35483. */
  35484. execute(): void;
  35485. /**
  35486. * Serializes the actions and its related information.
  35487. * @param parent defines the object to serialize in
  35488. * @returns the serialized object
  35489. */
  35490. serialize(parent: any): any;
  35491. }
  35492. }
  35493. declare module BABYLON {
  35494. /**
  35495. * This defines an action responsible to change the value of a property
  35496. * by interpolating between its current value and the newly set one once triggered.
  35497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35498. */
  35499. export class InterpolateValueAction extends Action {
  35500. /**
  35501. * Defines the path of the property where the value should be interpolated
  35502. */
  35503. propertyPath: string;
  35504. /**
  35505. * Defines the target value at the end of the interpolation.
  35506. */
  35507. value: any;
  35508. /**
  35509. * Defines the time it will take for the property to interpolate to the value.
  35510. */
  35511. duration: number;
  35512. /**
  35513. * Defines if the other scene animations should be stopped when the action has been triggered
  35514. */
  35515. stopOtherAnimations?: boolean;
  35516. /**
  35517. * Defines a callback raised once the interpolation animation has been done.
  35518. */
  35519. onInterpolationDone?: () => void;
  35520. /**
  35521. * Observable triggered once the interpolation animation has been done.
  35522. */
  35523. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35524. private _target;
  35525. private _effectiveTarget;
  35526. private _property;
  35527. /**
  35528. * Instantiate the action
  35529. * @param triggerOptions defines the trigger options
  35530. * @param target defines the object containing the value to interpolate
  35531. * @param propertyPath defines the path to the property in the target object
  35532. * @param value defines the target value at the end of the interpolation
  35533. * @param duration deines the time it will take for the property to interpolate to the value.
  35534. * @param condition defines the trigger related conditions
  35535. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35536. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35537. */
  35538. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35539. /** @hidden */
  35540. _prepare(): void;
  35541. /**
  35542. * Execute the action starts the value interpolation.
  35543. */
  35544. execute(): void;
  35545. /**
  35546. * Serializes the actions and its related information.
  35547. * @param parent defines the object to serialize in
  35548. * @returns the serialized object
  35549. */
  35550. serialize(parent: any): any;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. /**
  35555. * Options allowed during the creation of a sound track.
  35556. */
  35557. export interface ISoundTrackOptions {
  35558. /**
  35559. * The volume the sound track should take during creation
  35560. */
  35561. volume?: number;
  35562. /**
  35563. * Define if the sound track is the main sound track of the scene
  35564. */
  35565. mainTrack?: boolean;
  35566. }
  35567. /**
  35568. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35569. * It will be also used in a future release to apply effects on a specific track.
  35570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35571. */
  35572. export class SoundTrack {
  35573. /**
  35574. * The unique identifier of the sound track in the scene.
  35575. */
  35576. id: number;
  35577. /**
  35578. * The list of sounds included in the sound track.
  35579. */
  35580. soundCollection: Array<Sound>;
  35581. private _outputAudioNode;
  35582. private _scene;
  35583. private _isMainTrack;
  35584. private _connectedAnalyser;
  35585. private _options;
  35586. private _isInitialized;
  35587. /**
  35588. * Creates a new sound track.
  35589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35590. * @param scene Define the scene the sound track belongs to
  35591. * @param options
  35592. */
  35593. constructor(scene: Scene, options?: ISoundTrackOptions);
  35594. private _initializeSoundTrackAudioGraph;
  35595. /**
  35596. * Release the sound track and its associated resources
  35597. */
  35598. dispose(): void;
  35599. /**
  35600. * Adds a sound to this sound track
  35601. * @param sound define the cound to add
  35602. * @ignoreNaming
  35603. */
  35604. AddSound(sound: Sound): void;
  35605. /**
  35606. * Removes a sound to this sound track
  35607. * @param sound define the cound to remove
  35608. * @ignoreNaming
  35609. */
  35610. RemoveSound(sound: Sound): void;
  35611. /**
  35612. * Set a global volume for the full sound track.
  35613. * @param newVolume Define the new volume of the sound track
  35614. */
  35615. setVolume(newVolume: number): void;
  35616. /**
  35617. * Switch the panning model to HRTF:
  35618. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35620. */
  35621. switchPanningModelToHRTF(): void;
  35622. /**
  35623. * Switch the panning model to Equal Power:
  35624. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35626. */
  35627. switchPanningModelToEqualPower(): void;
  35628. /**
  35629. * Connect the sound track to an audio analyser allowing some amazing
  35630. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35632. * @param analyser The analyser to connect to the engine
  35633. */
  35634. connectToAnalyser(analyser: Analyser): void;
  35635. }
  35636. }
  35637. declare module BABYLON {
  35638. interface AbstractScene {
  35639. /**
  35640. * The list of sounds used in the scene.
  35641. */
  35642. sounds: Nullable<Array<Sound>>;
  35643. }
  35644. interface Scene {
  35645. /**
  35646. * @hidden
  35647. * Backing field
  35648. */
  35649. _mainSoundTrack: SoundTrack;
  35650. /**
  35651. * The main sound track played by the scene.
  35652. * It cotains your primary collection of sounds.
  35653. */
  35654. mainSoundTrack: SoundTrack;
  35655. /**
  35656. * The list of sound tracks added to the scene
  35657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35658. */
  35659. soundTracks: Nullable<Array<SoundTrack>>;
  35660. /**
  35661. * Gets a sound using a given name
  35662. * @param name defines the name to search for
  35663. * @return the found sound or null if not found at all.
  35664. */
  35665. getSoundByName(name: string): Nullable<Sound>;
  35666. /**
  35667. * Gets or sets if audio support is enabled
  35668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35669. */
  35670. audioEnabled: boolean;
  35671. /**
  35672. * Gets or sets if audio will be output to headphones
  35673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35674. */
  35675. headphone: boolean;
  35676. /**
  35677. * Gets or sets custom audio listener position provider
  35678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35679. */
  35680. audioListenerPositionProvider: Nullable<() => Vector3>;
  35681. /**
  35682. * Gets or sets a refresh rate when using 3D audio positioning
  35683. */
  35684. audioPositioningRefreshRate: number;
  35685. }
  35686. /**
  35687. * Defines the sound scene component responsible to manage any sounds
  35688. * in a given scene.
  35689. */
  35690. export class AudioSceneComponent implements ISceneSerializableComponent {
  35691. /**
  35692. * The component name helpfull to identify the component in the list of scene components.
  35693. */
  35694. readonly name: string;
  35695. /**
  35696. * The scene the component belongs to.
  35697. */
  35698. scene: Scene;
  35699. private _audioEnabled;
  35700. /**
  35701. * Gets whether audio is enabled or not.
  35702. * Please use related enable/disable method to switch state.
  35703. */
  35704. readonly audioEnabled: boolean;
  35705. private _headphone;
  35706. /**
  35707. * Gets whether audio is outputing to headphone or not.
  35708. * Please use the according Switch methods to change output.
  35709. */
  35710. readonly headphone: boolean;
  35711. /**
  35712. * Gets or sets a refresh rate when using 3D audio positioning
  35713. */
  35714. audioPositioningRefreshRate: number;
  35715. private _audioListenerPositionProvider;
  35716. /**
  35717. * Gets the current audio listener position provider
  35718. */
  35719. /**
  35720. * Sets a custom listener position for all sounds in the scene
  35721. * By default, this is the position of the first active camera
  35722. */
  35723. audioListenerPositionProvider: Nullable<() => Vector3>;
  35724. /**
  35725. * Creates a new instance of the component for the given scene
  35726. * @param scene Defines the scene to register the component in
  35727. */
  35728. constructor(scene: Scene);
  35729. /**
  35730. * Registers the component in a given scene
  35731. */
  35732. register(): void;
  35733. /**
  35734. * Rebuilds the elements related to this component in case of
  35735. * context lost for instance.
  35736. */
  35737. rebuild(): void;
  35738. /**
  35739. * Serializes the component data to the specified json object
  35740. * @param serializationObject The object to serialize to
  35741. */
  35742. serialize(serializationObject: any): void;
  35743. /**
  35744. * Adds all the elements from the container to the scene
  35745. * @param container the container holding the elements
  35746. */
  35747. addFromContainer(container: AbstractScene): void;
  35748. /**
  35749. * Removes all the elements in the container from the scene
  35750. * @param container contains the elements to remove
  35751. * @param dispose if the removed element should be disposed (default: false)
  35752. */
  35753. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35754. /**
  35755. * Disposes the component and the associated ressources.
  35756. */
  35757. dispose(): void;
  35758. /**
  35759. * Disables audio in the associated scene.
  35760. */
  35761. disableAudio(): void;
  35762. /**
  35763. * Enables audio in the associated scene.
  35764. */
  35765. enableAudio(): void;
  35766. /**
  35767. * Switch audio to headphone output.
  35768. */
  35769. switchAudioModeForHeadphones(): void;
  35770. /**
  35771. * Switch audio to normal speakers.
  35772. */
  35773. switchAudioModeForNormalSpeakers(): void;
  35774. private _cachedCameraDirection;
  35775. private _cachedCameraPosition;
  35776. private _lastCheck;
  35777. private _afterRender;
  35778. }
  35779. }
  35780. declare module BABYLON {
  35781. /**
  35782. * Wraps one or more Sound objects and selects one with random weight for playback.
  35783. */
  35784. export class WeightedSound {
  35785. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35786. loop: boolean;
  35787. private _coneInnerAngle;
  35788. private _coneOuterAngle;
  35789. private _volume;
  35790. /** A Sound is currently playing. */
  35791. isPlaying: boolean;
  35792. /** A Sound is currently paused. */
  35793. isPaused: boolean;
  35794. private _sounds;
  35795. private _weights;
  35796. private _currentIndex?;
  35797. /**
  35798. * Creates a new WeightedSound from the list of sounds given.
  35799. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35800. * @param sounds Array of Sounds that will be selected from.
  35801. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35802. */
  35803. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35804. /**
  35805. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35806. */
  35807. /**
  35808. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35809. */
  35810. directionalConeInnerAngle: number;
  35811. /**
  35812. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35813. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35814. */
  35815. /**
  35816. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35817. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35818. */
  35819. directionalConeOuterAngle: number;
  35820. /**
  35821. * Playback volume.
  35822. */
  35823. /**
  35824. * Playback volume.
  35825. */
  35826. volume: number;
  35827. private _onended;
  35828. /**
  35829. * Suspend playback
  35830. */
  35831. pause(): void;
  35832. /**
  35833. * Stop playback
  35834. */
  35835. stop(): void;
  35836. /**
  35837. * Start playback.
  35838. * @param startOffset Position the clip head at a specific time in seconds.
  35839. */
  35840. play(startOffset?: number): void;
  35841. }
  35842. }
  35843. declare module BABYLON {
  35844. /**
  35845. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35846. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35847. */
  35848. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35849. /**
  35850. * Gets the name of the behavior.
  35851. */
  35852. readonly name: string;
  35853. /**
  35854. * The easing function used by animations
  35855. */
  35856. static EasingFunction: BackEase;
  35857. /**
  35858. * The easing mode used by animations
  35859. */
  35860. static EasingMode: number;
  35861. /**
  35862. * The duration of the animation, in milliseconds
  35863. */
  35864. transitionDuration: number;
  35865. /**
  35866. * Length of the distance animated by the transition when lower radius is reached
  35867. */
  35868. lowerRadiusTransitionRange: number;
  35869. /**
  35870. * Length of the distance animated by the transition when upper radius is reached
  35871. */
  35872. upperRadiusTransitionRange: number;
  35873. private _autoTransitionRange;
  35874. /**
  35875. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35876. */
  35877. /**
  35878. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35879. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35880. */
  35881. autoTransitionRange: boolean;
  35882. private _attachedCamera;
  35883. private _onAfterCheckInputsObserver;
  35884. private _onMeshTargetChangedObserver;
  35885. /**
  35886. * Initializes the behavior.
  35887. */
  35888. init(): void;
  35889. /**
  35890. * Attaches the behavior to its arc rotate camera.
  35891. * @param camera Defines the camera to attach the behavior to
  35892. */
  35893. attach(camera: ArcRotateCamera): void;
  35894. /**
  35895. * Detaches the behavior from its current arc rotate camera.
  35896. */
  35897. detach(): void;
  35898. private _radiusIsAnimating;
  35899. private _radiusBounceTransition;
  35900. private _animatables;
  35901. private _cachedWheelPrecision;
  35902. /**
  35903. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35904. * @param radiusLimit The limit to check against.
  35905. * @return Bool to indicate if at limit.
  35906. */
  35907. private _isRadiusAtLimit;
  35908. /**
  35909. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35910. * @param radiusDelta The delta by which to animate to. Can be negative.
  35911. */
  35912. private _applyBoundRadiusAnimation;
  35913. /**
  35914. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35915. */
  35916. protected _clearAnimationLocks(): void;
  35917. /**
  35918. * Stops and removes all animations that have been applied to the camera
  35919. */
  35920. stopAllAnimations(): void;
  35921. }
  35922. }
  35923. declare module BABYLON {
  35924. /**
  35925. * 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.
  35926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35927. */
  35928. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35929. /**
  35930. * Gets the name of the behavior.
  35931. */
  35932. readonly name: string;
  35933. private _mode;
  35934. private _radiusScale;
  35935. private _positionScale;
  35936. private _defaultElevation;
  35937. private _elevationReturnTime;
  35938. private _elevationReturnWaitTime;
  35939. private _zoomStopsAnimation;
  35940. private _framingTime;
  35941. /**
  35942. * The easing function used by animations
  35943. */
  35944. static EasingFunction: ExponentialEase;
  35945. /**
  35946. * The easing mode used by animations
  35947. */
  35948. static EasingMode: number;
  35949. /**
  35950. * Sets the current mode used by the behavior
  35951. */
  35952. /**
  35953. * Gets current mode used by the behavior.
  35954. */
  35955. mode: number;
  35956. /**
  35957. * Sets the scale applied to the radius (1 by default)
  35958. */
  35959. /**
  35960. * Gets the scale applied to the radius
  35961. */
  35962. radiusScale: number;
  35963. /**
  35964. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35965. */
  35966. /**
  35967. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35968. */
  35969. positionScale: number;
  35970. /**
  35971. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35972. * behaviour is triggered, in radians.
  35973. */
  35974. /**
  35975. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35976. * behaviour is triggered, in radians.
  35977. */
  35978. defaultElevation: number;
  35979. /**
  35980. * Sets the time (in milliseconds) taken to return to the default beta position.
  35981. * Negative value indicates camera should not return to default.
  35982. */
  35983. /**
  35984. * Gets the time (in milliseconds) taken to return to the default beta position.
  35985. * Negative value indicates camera should not return to default.
  35986. */
  35987. elevationReturnTime: number;
  35988. /**
  35989. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35990. */
  35991. /**
  35992. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35993. */
  35994. elevationReturnWaitTime: number;
  35995. /**
  35996. * Sets the flag that indicates if user zooming should stop animation.
  35997. */
  35998. /**
  35999. * Gets the flag that indicates if user zooming should stop animation.
  36000. */
  36001. zoomStopsAnimation: boolean;
  36002. /**
  36003. * Sets the transition time when framing the mesh, in milliseconds
  36004. */
  36005. /**
  36006. * Gets the transition time when framing the mesh, in milliseconds
  36007. */
  36008. framingTime: number;
  36009. /**
  36010. * Define if the behavior should automatically change the configured
  36011. * camera limits and sensibilities.
  36012. */
  36013. autoCorrectCameraLimitsAndSensibility: boolean;
  36014. private _onPrePointerObservableObserver;
  36015. private _onAfterCheckInputsObserver;
  36016. private _onMeshTargetChangedObserver;
  36017. private _attachedCamera;
  36018. private _isPointerDown;
  36019. private _lastInteractionTime;
  36020. /**
  36021. * Initializes the behavior.
  36022. */
  36023. init(): void;
  36024. /**
  36025. * Attaches the behavior to its arc rotate camera.
  36026. * @param camera Defines the camera to attach the behavior to
  36027. */
  36028. attach(camera: ArcRotateCamera): void;
  36029. /**
  36030. * Detaches the behavior from its current arc rotate camera.
  36031. */
  36032. detach(): void;
  36033. private _animatables;
  36034. private _betaIsAnimating;
  36035. private _betaTransition;
  36036. private _radiusTransition;
  36037. private _vectorTransition;
  36038. /**
  36039. * Targets the given mesh and updates zoom level accordingly.
  36040. * @param mesh The mesh to target.
  36041. * @param radius Optional. If a cached radius position already exists, overrides default.
  36042. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36045. */
  36046. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36047. /**
  36048. * Targets the given mesh with its children and updates zoom level accordingly.
  36049. * @param mesh The mesh to target.
  36050. * @param radius Optional. If a cached radius position already exists, overrides default.
  36051. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36052. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36053. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36054. */
  36055. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36056. /**
  36057. * Targets the given meshes with their children and updates zoom level accordingly.
  36058. * @param meshes The mesh to target.
  36059. * @param radius Optional. If a cached radius position already exists, overrides default.
  36060. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36061. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36062. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36063. */
  36064. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36065. /**
  36066. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36067. * @param minimumWorld Determines the smaller position of the bounding box extend
  36068. * @param maximumWorld Determines the bigger position of the bounding box extend
  36069. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36070. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36071. */
  36072. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36073. /**
  36074. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36075. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36076. * frustum width.
  36077. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36078. * to fully enclose the mesh in the viewing frustum.
  36079. */
  36080. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36081. /**
  36082. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36083. * is automatically returned to its default position (expected to be above ground plane).
  36084. */
  36085. private _maintainCameraAboveGround;
  36086. /**
  36087. * Returns the frustum slope based on the canvas ratio and camera FOV
  36088. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36089. */
  36090. private _getFrustumSlope;
  36091. /**
  36092. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36093. */
  36094. private _clearAnimationLocks;
  36095. /**
  36096. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36097. */
  36098. private _applyUserInteraction;
  36099. /**
  36100. * Stops and removes all animations that have been applied to the camera
  36101. */
  36102. stopAllAnimations(): void;
  36103. /**
  36104. * Gets a value indicating if the user is moving the camera
  36105. */
  36106. readonly isUserIsMoving: boolean;
  36107. /**
  36108. * The camera can move all the way towards the mesh.
  36109. */
  36110. static IgnoreBoundsSizeMode: number;
  36111. /**
  36112. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36113. */
  36114. static FitFrustumSidesMode: number;
  36115. }
  36116. }
  36117. declare module BABYLON {
  36118. /**
  36119. * Base class for Camera Pointer Inputs.
  36120. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36121. * for example usage.
  36122. */
  36123. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36124. /**
  36125. * Defines the camera the input is attached to.
  36126. */
  36127. abstract camera: Camera;
  36128. /**
  36129. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36130. */
  36131. protected _altKey: boolean;
  36132. protected _ctrlKey: boolean;
  36133. protected _metaKey: boolean;
  36134. protected _shiftKey: boolean;
  36135. /**
  36136. * Which mouse buttons were pressed at time of last mouse event.
  36137. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36138. */
  36139. protected _buttonsPressed: number;
  36140. /**
  36141. * Defines the buttons associated with the input to handle camera move.
  36142. */
  36143. buttons: number[];
  36144. /**
  36145. * Attach the input controls to a specific dom element to get the input from.
  36146. * @param element Defines the element the controls should be listened from
  36147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36148. */
  36149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36150. /**
  36151. * Detach the current controls from the specified dom element.
  36152. * @param element Defines the element to stop listening the inputs from
  36153. */
  36154. detachControl(element: Nullable<HTMLElement>): void;
  36155. /**
  36156. * Gets the class name of the current input.
  36157. * @returns the class name
  36158. */
  36159. getClassName(): string;
  36160. /**
  36161. * Get the friendly name associated with the input class.
  36162. * @returns the input friendly name
  36163. */
  36164. getSimpleName(): string;
  36165. /**
  36166. * Called on pointer POINTERDOUBLETAP event.
  36167. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36168. */
  36169. protected onDoubleTap(type: string): void;
  36170. /**
  36171. * Called on pointer POINTERMOVE event if only a single touch is active.
  36172. * Override this method to provide functionality.
  36173. */
  36174. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36175. /**
  36176. * Called on pointer POINTERMOVE event if multiple touches are active.
  36177. * Override this method to provide functionality.
  36178. */
  36179. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36180. /**
  36181. * Called on JS contextmenu event.
  36182. * Override this method to provide functionality.
  36183. */
  36184. protected onContextMenu(evt: PointerEvent): void;
  36185. /**
  36186. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36187. * press.
  36188. * Override this method to provide functionality.
  36189. */
  36190. protected onButtonDown(evt: PointerEvent): void;
  36191. /**
  36192. * Called each time a new POINTERUP event occurs. Ie, for each button
  36193. * release.
  36194. * Override this method to provide functionality.
  36195. */
  36196. protected onButtonUp(evt: PointerEvent): void;
  36197. /**
  36198. * Called when window becomes inactive.
  36199. * Override this method to provide functionality.
  36200. */
  36201. protected onLostFocus(): void;
  36202. private _pointerInput;
  36203. private _observer;
  36204. private _onLostFocus;
  36205. private pointA;
  36206. private pointB;
  36207. }
  36208. }
  36209. declare module BABYLON {
  36210. /**
  36211. * Manage the pointers inputs to control an arc rotate camera.
  36212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36213. */
  36214. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36215. /**
  36216. * Defines the camera the input is attached to.
  36217. */
  36218. camera: ArcRotateCamera;
  36219. /**
  36220. * Gets the class name of the current input.
  36221. * @returns the class name
  36222. */
  36223. getClassName(): string;
  36224. /**
  36225. * Defines the buttons associated with the input to handle camera move.
  36226. */
  36227. buttons: number[];
  36228. /**
  36229. * Defines the pointer angular sensibility along the X axis or how fast is
  36230. * the camera rotating.
  36231. */
  36232. angularSensibilityX: number;
  36233. /**
  36234. * Defines the pointer angular sensibility along the Y axis or how fast is
  36235. * the camera rotating.
  36236. */
  36237. angularSensibilityY: number;
  36238. /**
  36239. * Defines the pointer pinch precision or how fast is the camera zooming.
  36240. */
  36241. pinchPrecision: number;
  36242. /**
  36243. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36244. * from 0.
  36245. * It defines the percentage of current camera.radius to use as delta when
  36246. * pinch zoom is used.
  36247. */
  36248. pinchDeltaPercentage: number;
  36249. /**
  36250. * Defines the pointer panning sensibility or how fast is the camera moving.
  36251. */
  36252. panningSensibility: number;
  36253. /**
  36254. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36255. */
  36256. multiTouchPanning: boolean;
  36257. /**
  36258. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36259. * zoom (pinch) through multitouch.
  36260. */
  36261. multiTouchPanAndZoom: boolean;
  36262. /**
  36263. * Revers pinch action direction.
  36264. */
  36265. pinchInwards: boolean;
  36266. private _isPanClick;
  36267. private _twoFingerActivityCount;
  36268. private _isPinching;
  36269. /**
  36270. * Called on pointer POINTERMOVE event if only a single touch is active.
  36271. */
  36272. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36273. /**
  36274. * Called on pointer POINTERDOUBLETAP event.
  36275. */
  36276. protected onDoubleTap(type: string): void;
  36277. /**
  36278. * Called on pointer POINTERMOVE event if multiple touches are active.
  36279. */
  36280. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36281. /**
  36282. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36283. * press.
  36284. */
  36285. protected onButtonDown(evt: PointerEvent): void;
  36286. /**
  36287. * Called each time a new POINTERUP event occurs. Ie, for each button
  36288. * release.
  36289. */
  36290. protected onButtonUp(evt: PointerEvent): void;
  36291. /**
  36292. * Called when window becomes inactive.
  36293. */
  36294. protected onLostFocus(): void;
  36295. }
  36296. }
  36297. declare module BABYLON {
  36298. /**
  36299. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36301. */
  36302. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36303. /**
  36304. * Defines the camera the input is attached to.
  36305. */
  36306. camera: ArcRotateCamera;
  36307. /**
  36308. * Defines the list of key codes associated with the up action (increase alpha)
  36309. */
  36310. keysUp: number[];
  36311. /**
  36312. * Defines the list of key codes associated with the down action (decrease alpha)
  36313. */
  36314. keysDown: number[];
  36315. /**
  36316. * Defines the list of key codes associated with the left action (increase beta)
  36317. */
  36318. keysLeft: number[];
  36319. /**
  36320. * Defines the list of key codes associated with the right action (decrease beta)
  36321. */
  36322. keysRight: number[];
  36323. /**
  36324. * Defines the list of key codes associated with the reset action.
  36325. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36326. */
  36327. keysReset: number[];
  36328. /**
  36329. * Defines the panning sensibility of the inputs.
  36330. * (How fast is the camera paning)
  36331. */
  36332. panningSensibility: number;
  36333. /**
  36334. * Defines the zooming sensibility of the inputs.
  36335. * (How fast is the camera zooming)
  36336. */
  36337. zoomingSensibility: number;
  36338. /**
  36339. * Defines wether maintaining the alt key down switch the movement mode from
  36340. * orientation to zoom.
  36341. */
  36342. useAltToZoom: boolean;
  36343. /**
  36344. * Rotation speed of the camera
  36345. */
  36346. angularSpeed: number;
  36347. private _keys;
  36348. private _ctrlPressed;
  36349. private _altPressed;
  36350. private _onCanvasBlurObserver;
  36351. private _onKeyboardObserver;
  36352. private _engine;
  36353. private _scene;
  36354. /**
  36355. * Attach the input controls to a specific dom element to get the input from.
  36356. * @param element Defines the element the controls should be listened from
  36357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36358. */
  36359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36360. /**
  36361. * Detach the current controls from the specified dom element.
  36362. * @param element Defines the element to stop listening the inputs from
  36363. */
  36364. detachControl(element: Nullable<HTMLElement>): void;
  36365. /**
  36366. * Update the current camera state depending on the inputs that have been used this frame.
  36367. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36368. */
  36369. checkInputs(): void;
  36370. /**
  36371. * Gets the class name of the current intput.
  36372. * @returns the class name
  36373. */
  36374. getClassName(): string;
  36375. /**
  36376. * Get the friendly name associated with the input class.
  36377. * @returns the input friendly name
  36378. */
  36379. getSimpleName(): string;
  36380. }
  36381. }
  36382. declare module BABYLON {
  36383. /**
  36384. * Manage the mouse wheel inputs to control an arc rotate camera.
  36385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36386. */
  36387. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36388. /**
  36389. * Defines the camera the input is attached to.
  36390. */
  36391. camera: ArcRotateCamera;
  36392. /**
  36393. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36394. */
  36395. wheelPrecision: number;
  36396. /**
  36397. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36398. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36399. */
  36400. wheelDeltaPercentage: number;
  36401. private _wheel;
  36402. private _observer;
  36403. private computeDeltaFromMouseWheelLegacyEvent;
  36404. /**
  36405. * Attach the input controls to a specific dom element to get the input from.
  36406. * @param element Defines the element the controls should be listened from
  36407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36408. */
  36409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36410. /**
  36411. * Detach the current controls from the specified dom element.
  36412. * @param element Defines the element to stop listening the inputs from
  36413. */
  36414. detachControl(element: Nullable<HTMLElement>): void;
  36415. /**
  36416. * Gets the class name of the current intput.
  36417. * @returns the class name
  36418. */
  36419. getClassName(): string;
  36420. /**
  36421. * Get the friendly name associated with the input class.
  36422. * @returns the input friendly name
  36423. */
  36424. getSimpleName(): string;
  36425. }
  36426. }
  36427. declare module BABYLON {
  36428. /**
  36429. * Default Inputs manager for the ArcRotateCamera.
  36430. * It groups all the default supported inputs for ease of use.
  36431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36432. */
  36433. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36434. /**
  36435. * Instantiates a new ArcRotateCameraInputsManager.
  36436. * @param camera Defines the camera the inputs belong to
  36437. */
  36438. constructor(camera: ArcRotateCamera);
  36439. /**
  36440. * Add mouse wheel input support to the input manager.
  36441. * @returns the current input manager
  36442. */
  36443. addMouseWheel(): ArcRotateCameraInputsManager;
  36444. /**
  36445. * Add pointers input support to the input manager.
  36446. * @returns the current input manager
  36447. */
  36448. addPointers(): ArcRotateCameraInputsManager;
  36449. /**
  36450. * Add keyboard input support to the input manager.
  36451. * @returns the current input manager
  36452. */
  36453. addKeyboard(): ArcRotateCameraInputsManager;
  36454. }
  36455. }
  36456. declare module BABYLON {
  36457. /**
  36458. * This represents an orbital type of camera.
  36459. *
  36460. * 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.
  36461. * 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.
  36462. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36463. */
  36464. export class ArcRotateCamera extends TargetCamera {
  36465. /**
  36466. * Defines the rotation angle of the camera along the longitudinal axis.
  36467. */
  36468. alpha: number;
  36469. /**
  36470. * Defines the rotation angle of the camera along the latitudinal axis.
  36471. */
  36472. beta: number;
  36473. /**
  36474. * Defines the radius of the camera from it s target point.
  36475. */
  36476. radius: number;
  36477. protected _target: Vector3;
  36478. protected _targetHost: Nullable<AbstractMesh>;
  36479. /**
  36480. * Defines the target point of the camera.
  36481. * The camera looks towards it form the radius distance.
  36482. */
  36483. target: Vector3;
  36484. /**
  36485. * Define the current local position of the camera in the scene
  36486. */
  36487. position: Vector3;
  36488. protected _upVector: Vector3;
  36489. protected _upToYMatrix: Matrix;
  36490. protected _YToUpMatrix: Matrix;
  36491. /**
  36492. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36493. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36494. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36495. */
  36496. upVector: Vector3;
  36497. /**
  36498. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36499. */
  36500. setMatUp(): void;
  36501. /**
  36502. * Current inertia value on the longitudinal axis.
  36503. * The bigger this number the longer it will take for the camera to stop.
  36504. */
  36505. inertialAlphaOffset: number;
  36506. /**
  36507. * Current inertia value on the latitudinal axis.
  36508. * The bigger this number the longer it will take for the camera to stop.
  36509. */
  36510. inertialBetaOffset: number;
  36511. /**
  36512. * Current inertia value on the radius axis.
  36513. * The bigger this number the longer it will take for the camera to stop.
  36514. */
  36515. inertialRadiusOffset: number;
  36516. /**
  36517. * Minimum allowed angle on the longitudinal axis.
  36518. * This can help limiting how the Camera is able to move in the scene.
  36519. */
  36520. lowerAlphaLimit: Nullable<number>;
  36521. /**
  36522. * Maximum allowed angle on the longitudinal axis.
  36523. * This can help limiting how the Camera is able to move in the scene.
  36524. */
  36525. upperAlphaLimit: Nullable<number>;
  36526. /**
  36527. * Minimum allowed angle on the latitudinal axis.
  36528. * This can help limiting how the Camera is able to move in the scene.
  36529. */
  36530. lowerBetaLimit: number;
  36531. /**
  36532. * Maximum allowed angle on the latitudinal axis.
  36533. * This can help limiting how the Camera is able to move in the scene.
  36534. */
  36535. upperBetaLimit: number;
  36536. /**
  36537. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36538. * This can help limiting how the Camera is able to move in the scene.
  36539. */
  36540. lowerRadiusLimit: Nullable<number>;
  36541. /**
  36542. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36543. * This can help limiting how the Camera is able to move in the scene.
  36544. */
  36545. upperRadiusLimit: Nullable<number>;
  36546. /**
  36547. * Defines the current inertia value used during panning of the camera along the X axis.
  36548. */
  36549. inertialPanningX: number;
  36550. /**
  36551. * Defines the current inertia value used during panning of the camera along the Y axis.
  36552. */
  36553. inertialPanningY: number;
  36554. /**
  36555. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36556. * Basically if your fingers moves away from more than this distance you will be considered
  36557. * in pinch mode.
  36558. */
  36559. pinchToPanMaxDistance: number;
  36560. /**
  36561. * Defines the maximum distance the camera can pan.
  36562. * This could help keeping the cammera always in your scene.
  36563. */
  36564. panningDistanceLimit: Nullable<number>;
  36565. /**
  36566. * Defines the target of the camera before paning.
  36567. */
  36568. panningOriginTarget: Vector3;
  36569. /**
  36570. * Defines the value of the inertia used during panning.
  36571. * 0 would mean stop inertia and one would mean no decelleration at all.
  36572. */
  36573. panningInertia: number;
  36574. /**
  36575. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36576. */
  36577. angularSensibilityX: number;
  36578. /**
  36579. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36580. */
  36581. angularSensibilityY: number;
  36582. /**
  36583. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36584. */
  36585. pinchPrecision: number;
  36586. /**
  36587. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36588. * It will be used instead of pinchDeltaPrecision if different from 0.
  36589. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36590. */
  36591. pinchDeltaPercentage: number;
  36592. /**
  36593. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36594. */
  36595. panningSensibility: number;
  36596. /**
  36597. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36598. */
  36599. keysUp: number[];
  36600. /**
  36601. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36602. */
  36603. keysDown: number[];
  36604. /**
  36605. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36606. */
  36607. keysLeft: number[];
  36608. /**
  36609. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36610. */
  36611. keysRight: number[];
  36612. /**
  36613. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36614. */
  36615. wheelPrecision: number;
  36616. /**
  36617. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36618. * It will be used instead of pinchDeltaPrecision if different from 0.
  36619. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36620. */
  36621. wheelDeltaPercentage: number;
  36622. /**
  36623. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36624. */
  36625. zoomOnFactor: number;
  36626. /**
  36627. * Defines a screen offset for the camera position.
  36628. */
  36629. targetScreenOffset: Vector2;
  36630. /**
  36631. * Allows the camera to be completely reversed.
  36632. * If false the camera can not arrive upside down.
  36633. */
  36634. allowUpsideDown: boolean;
  36635. /**
  36636. * Define if double tap/click is used to restore the previously saved state of the camera.
  36637. */
  36638. useInputToRestoreState: boolean;
  36639. /** @hidden */
  36640. _viewMatrix: Matrix;
  36641. /** @hidden */
  36642. _useCtrlForPanning: boolean;
  36643. /** @hidden */
  36644. _panningMouseButton: number;
  36645. /**
  36646. * Defines the input associated to the camera.
  36647. */
  36648. inputs: ArcRotateCameraInputsManager;
  36649. /** @hidden */
  36650. _reset: () => void;
  36651. /**
  36652. * Defines the allowed panning axis.
  36653. */
  36654. panningAxis: Vector3;
  36655. protected _localDirection: Vector3;
  36656. protected _transformedDirection: Vector3;
  36657. private _bouncingBehavior;
  36658. /**
  36659. * Gets the bouncing behavior of the camera if it has been enabled.
  36660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36661. */
  36662. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36663. /**
  36664. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36665. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36666. */
  36667. useBouncingBehavior: boolean;
  36668. private _framingBehavior;
  36669. /**
  36670. * Gets the framing behavior of the camera if it has been enabled.
  36671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36672. */
  36673. readonly framingBehavior: Nullable<FramingBehavior>;
  36674. /**
  36675. * Defines if the framing behavior of the camera is enabled on the camera.
  36676. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36677. */
  36678. useFramingBehavior: boolean;
  36679. private _autoRotationBehavior;
  36680. /**
  36681. * Gets the auto rotation behavior of the camera if it has been enabled.
  36682. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36683. */
  36684. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36685. /**
  36686. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36688. */
  36689. useAutoRotationBehavior: boolean;
  36690. /**
  36691. * Observable triggered when the mesh target has been changed on the camera.
  36692. */
  36693. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36694. /**
  36695. * Event raised when the camera is colliding with a mesh.
  36696. */
  36697. onCollide: (collidedMesh: AbstractMesh) => void;
  36698. /**
  36699. * Defines whether the camera should check collision with the objects oh the scene.
  36700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36701. */
  36702. checkCollisions: boolean;
  36703. /**
  36704. * Defines the collision radius of the camera.
  36705. * This simulates a sphere around the camera.
  36706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36707. */
  36708. collisionRadius: Vector3;
  36709. protected _collider: Collider;
  36710. protected _previousPosition: Vector3;
  36711. protected _collisionVelocity: Vector3;
  36712. protected _newPosition: Vector3;
  36713. protected _previousAlpha: number;
  36714. protected _previousBeta: number;
  36715. protected _previousRadius: number;
  36716. protected _collisionTriggered: boolean;
  36717. protected _targetBoundingCenter: Nullable<Vector3>;
  36718. private _computationVector;
  36719. /**
  36720. * Instantiates a new ArcRotateCamera in a given scene
  36721. * @param name Defines the name of the camera
  36722. * @param alpha Defines the camera rotation along the logitudinal axis
  36723. * @param beta Defines the camera rotation along the latitudinal axis
  36724. * @param radius Defines the camera distance from its target
  36725. * @param target Defines the camera target
  36726. * @param scene Defines the scene the camera belongs to
  36727. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36728. */
  36729. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36730. /** @hidden */
  36731. _initCache(): void;
  36732. /** @hidden */
  36733. _updateCache(ignoreParentClass?: boolean): void;
  36734. protected _getTargetPosition(): Vector3;
  36735. private _storedAlpha;
  36736. private _storedBeta;
  36737. private _storedRadius;
  36738. private _storedTarget;
  36739. private _storedTargetScreenOffset;
  36740. /**
  36741. * Stores the current state of the camera (alpha, beta, radius and target)
  36742. * @returns the camera itself
  36743. */
  36744. storeState(): Camera;
  36745. /**
  36746. * @hidden
  36747. * Restored camera state. You must call storeState() first
  36748. */
  36749. _restoreStateValues(): boolean;
  36750. /** @hidden */
  36751. _isSynchronizedViewMatrix(): boolean;
  36752. /**
  36753. * Attached controls to the current camera.
  36754. * @param element Defines the element the controls should be listened from
  36755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36756. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36757. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36758. */
  36759. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36760. /**
  36761. * Detach the current controls from the camera.
  36762. * The camera will stop reacting to inputs.
  36763. * @param element Defines the element to stop listening the inputs from
  36764. */
  36765. detachControl(element: HTMLElement): void;
  36766. /** @hidden */
  36767. _checkInputs(): void;
  36768. protected _checkLimits(): void;
  36769. /**
  36770. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36771. */
  36772. rebuildAnglesAndRadius(): void;
  36773. /**
  36774. * Use a position to define the current camera related information like alpha, beta and radius
  36775. * @param position Defines the position to set the camera at
  36776. */
  36777. setPosition(position: Vector3): void;
  36778. /**
  36779. * Defines the target the camera should look at.
  36780. * This will automatically adapt alpha beta and radius to fit within the new target.
  36781. * @param target Defines the new target as a Vector or a mesh
  36782. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36783. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36784. */
  36785. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36786. /** @hidden */
  36787. _getViewMatrix(): Matrix;
  36788. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36789. /**
  36790. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36791. * @param meshes Defines the mesh to zoom on
  36792. * @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)
  36793. */
  36794. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36795. /**
  36796. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36797. * The target will be changed but the radius
  36798. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36799. * @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)
  36800. */
  36801. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36802. min: Vector3;
  36803. max: Vector3;
  36804. distance: number;
  36805. }, doNotUpdateMaxZ?: boolean): void;
  36806. /**
  36807. * @override
  36808. * Override Camera.createRigCamera
  36809. */
  36810. createRigCamera(name: string, cameraIndex: number): Camera;
  36811. /**
  36812. * @hidden
  36813. * @override
  36814. * Override Camera._updateRigCameras
  36815. */
  36816. _updateRigCameras(): void;
  36817. /**
  36818. * Destroy the camera and release the current resources hold by it.
  36819. */
  36820. dispose(): void;
  36821. /**
  36822. * Gets the current object class name.
  36823. * @return the class name
  36824. */
  36825. getClassName(): string;
  36826. }
  36827. }
  36828. declare module BABYLON {
  36829. /**
  36830. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36831. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36832. */
  36833. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36834. /**
  36835. * Gets the name of the behavior.
  36836. */
  36837. readonly name: string;
  36838. private _zoomStopsAnimation;
  36839. private _idleRotationSpeed;
  36840. private _idleRotationWaitTime;
  36841. private _idleRotationSpinupTime;
  36842. /**
  36843. * Sets the flag that indicates if user zooming should stop animation.
  36844. */
  36845. /**
  36846. * Gets the flag that indicates if user zooming should stop animation.
  36847. */
  36848. zoomStopsAnimation: boolean;
  36849. /**
  36850. * Sets the default speed at which the camera rotates around the model.
  36851. */
  36852. /**
  36853. * Gets the default speed at which the camera rotates around the model.
  36854. */
  36855. idleRotationSpeed: number;
  36856. /**
  36857. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36858. */
  36859. /**
  36860. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36861. */
  36862. idleRotationWaitTime: number;
  36863. /**
  36864. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36865. */
  36866. /**
  36867. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36868. */
  36869. idleRotationSpinupTime: number;
  36870. /**
  36871. * Gets a value indicating if the camera is currently rotating because of this behavior
  36872. */
  36873. readonly rotationInProgress: boolean;
  36874. private _onPrePointerObservableObserver;
  36875. private _onAfterCheckInputsObserver;
  36876. private _attachedCamera;
  36877. private _isPointerDown;
  36878. private _lastFrameTime;
  36879. private _lastInteractionTime;
  36880. private _cameraRotationSpeed;
  36881. /**
  36882. * Initializes the behavior.
  36883. */
  36884. init(): void;
  36885. /**
  36886. * Attaches the behavior to its arc rotate camera.
  36887. * @param camera Defines the camera to attach the behavior to
  36888. */
  36889. attach(camera: ArcRotateCamera): void;
  36890. /**
  36891. * Detaches the behavior from its current arc rotate camera.
  36892. */
  36893. detach(): void;
  36894. /**
  36895. * Returns true if user is scrolling.
  36896. * @return true if user is scrolling.
  36897. */
  36898. private _userIsZooming;
  36899. private _lastFrameRadius;
  36900. private _shouldAnimationStopForInteraction;
  36901. /**
  36902. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36903. */
  36904. private _applyUserInteraction;
  36905. private _userIsMoving;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. /**
  36910. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36911. */
  36912. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36913. private ui;
  36914. /**
  36915. * The name of the behavior
  36916. */
  36917. name: string;
  36918. /**
  36919. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36920. */
  36921. distanceAwayFromFace: number;
  36922. /**
  36923. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36924. */
  36925. distanceAwayFromBottomOfFace: number;
  36926. private _faceVectors;
  36927. private _target;
  36928. private _scene;
  36929. private _onRenderObserver;
  36930. private _tmpMatrix;
  36931. private _tmpVector;
  36932. /**
  36933. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36934. * @param ui The transform node that should be attched to the mesh
  36935. */
  36936. constructor(ui: TransformNode);
  36937. /**
  36938. * Initializes the behavior
  36939. */
  36940. init(): void;
  36941. private _closestFace;
  36942. private _zeroVector;
  36943. private _lookAtTmpMatrix;
  36944. private _lookAtToRef;
  36945. /**
  36946. * Attaches the AttachToBoxBehavior to the passed in mesh
  36947. * @param target The mesh that the specified node will be attached to
  36948. */
  36949. attach(target: Mesh): void;
  36950. /**
  36951. * Detaches the behavior from the mesh
  36952. */
  36953. detach(): void;
  36954. }
  36955. }
  36956. declare module BABYLON {
  36957. /**
  36958. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36959. */
  36960. export class FadeInOutBehavior implements Behavior<Mesh> {
  36961. /**
  36962. * Time in milliseconds to delay before fading in (Default: 0)
  36963. */
  36964. delay: number;
  36965. /**
  36966. * Time in milliseconds for the mesh to fade in (Default: 300)
  36967. */
  36968. fadeInTime: number;
  36969. private _millisecondsPerFrame;
  36970. private _hovered;
  36971. private _hoverValue;
  36972. private _ownerNode;
  36973. /**
  36974. * Instatiates the FadeInOutBehavior
  36975. */
  36976. constructor();
  36977. /**
  36978. * The name of the behavior
  36979. */
  36980. readonly name: string;
  36981. /**
  36982. * Initializes the behavior
  36983. */
  36984. init(): void;
  36985. /**
  36986. * Attaches the fade behavior on the passed in mesh
  36987. * @param ownerNode The mesh that will be faded in/out once attached
  36988. */
  36989. attach(ownerNode: Mesh): void;
  36990. /**
  36991. * Detaches the behavior from the mesh
  36992. */
  36993. detach(): void;
  36994. /**
  36995. * Triggers the mesh to begin fading in or out
  36996. * @param value if the object should fade in or out (true to fade in)
  36997. */
  36998. fadeIn(value: boolean): void;
  36999. private _update;
  37000. private _setAllVisibility;
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Class containing a set of static utilities functions for managing Pivots
  37006. * @hidden
  37007. */
  37008. export class PivotTools {
  37009. private static _PivotCached;
  37010. private static _OldPivotPoint;
  37011. private static _PivotTranslation;
  37012. private static _PivotTmpVector;
  37013. /** @hidden */
  37014. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37015. /** @hidden */
  37016. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37017. }
  37018. }
  37019. declare module BABYLON {
  37020. /**
  37021. * Class containing static functions to help procedurally build meshes
  37022. */
  37023. export class PlaneBuilder {
  37024. /**
  37025. * Creates a plane mesh
  37026. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37027. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37028. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37030. * * 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
  37031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37032. * @param name defines the name of the mesh
  37033. * @param options defines the options used to create the mesh
  37034. * @param scene defines the hosting scene
  37035. * @returns the plane mesh
  37036. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37037. */
  37038. static CreatePlane(name: string, options: {
  37039. size?: number;
  37040. width?: number;
  37041. height?: number;
  37042. sideOrientation?: number;
  37043. frontUVs?: Vector4;
  37044. backUVs?: Vector4;
  37045. updatable?: boolean;
  37046. sourcePlane?: Plane;
  37047. }, scene?: Nullable<Scene>): Mesh;
  37048. }
  37049. }
  37050. declare module BABYLON {
  37051. /**
  37052. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37053. */
  37054. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37055. private static _AnyMouseID;
  37056. /**
  37057. * Abstract mesh the behavior is set on
  37058. */
  37059. attachedNode: AbstractMesh;
  37060. private _dragPlane;
  37061. private _scene;
  37062. private _pointerObserver;
  37063. private _beforeRenderObserver;
  37064. private static _planeScene;
  37065. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37066. /**
  37067. * 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)
  37068. */
  37069. maxDragAngle: number;
  37070. /**
  37071. * @hidden
  37072. */
  37073. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37074. /**
  37075. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37076. */
  37077. currentDraggingPointerID: number;
  37078. /**
  37079. * The last position where the pointer hit the drag plane in world space
  37080. */
  37081. lastDragPosition: Vector3;
  37082. /**
  37083. * If the behavior is currently in a dragging state
  37084. */
  37085. dragging: boolean;
  37086. /**
  37087. * 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)
  37088. */
  37089. dragDeltaRatio: number;
  37090. /**
  37091. * If the drag plane orientation should be updated during the dragging (Default: true)
  37092. */
  37093. updateDragPlane: boolean;
  37094. private _debugMode;
  37095. private _moving;
  37096. /**
  37097. * Fires each time the attached mesh is dragged with the pointer
  37098. * * delta between last drag position and current drag position in world space
  37099. * * dragDistance along the drag axis
  37100. * * dragPlaneNormal normal of the current drag plane used during the drag
  37101. * * dragPlanePoint in world space where the drag intersects the drag plane
  37102. */
  37103. onDragObservable: Observable<{
  37104. delta: Vector3;
  37105. dragPlanePoint: Vector3;
  37106. dragPlaneNormal: Vector3;
  37107. dragDistance: number;
  37108. pointerId: number;
  37109. }>;
  37110. /**
  37111. * Fires each time a drag begins (eg. mouse down on mesh)
  37112. */
  37113. onDragStartObservable: Observable<{
  37114. dragPlanePoint: Vector3;
  37115. pointerId: number;
  37116. }>;
  37117. /**
  37118. * Fires each time a drag ends (eg. mouse release after drag)
  37119. */
  37120. onDragEndObservable: Observable<{
  37121. dragPlanePoint: Vector3;
  37122. pointerId: number;
  37123. }>;
  37124. /**
  37125. * If the attached mesh should be moved when dragged
  37126. */
  37127. moveAttached: boolean;
  37128. /**
  37129. * If the drag behavior will react to drag events (Default: true)
  37130. */
  37131. enabled: boolean;
  37132. /**
  37133. * If pointer events should start and release the drag (Default: true)
  37134. */
  37135. startAndReleaseDragOnPointerEvents: boolean;
  37136. /**
  37137. * If camera controls should be detached during the drag
  37138. */
  37139. detachCameraControls: boolean;
  37140. /**
  37141. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37142. */
  37143. useObjectOrienationForDragging: boolean;
  37144. private _options;
  37145. /**
  37146. * Creates a pointer drag behavior that can be attached to a mesh
  37147. * @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)
  37148. */
  37149. constructor(options?: {
  37150. dragAxis?: Vector3;
  37151. dragPlaneNormal?: Vector3;
  37152. });
  37153. /**
  37154. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37155. */
  37156. validateDrag: (targetPosition: Vector3) => boolean;
  37157. /**
  37158. * The name of the behavior
  37159. */
  37160. readonly name: string;
  37161. /**
  37162. * Initializes the behavior
  37163. */
  37164. init(): void;
  37165. private _tmpVector;
  37166. private _alternatePickedPoint;
  37167. private _worldDragAxis;
  37168. private _targetPosition;
  37169. private _attachedElement;
  37170. /**
  37171. * Attaches the drag behavior the passed in mesh
  37172. * @param ownerNode The mesh that will be dragged around once attached
  37173. * @param predicate Predicate to use for pick filtering
  37174. */
  37175. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37176. /**
  37177. * Force relase the drag action by code.
  37178. */
  37179. releaseDrag(): void;
  37180. private _startDragRay;
  37181. private _lastPointerRay;
  37182. /**
  37183. * Simulates the start of a pointer drag event on the behavior
  37184. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37185. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37186. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37187. */
  37188. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37189. private _startDrag;
  37190. private _dragDelta;
  37191. private _moveDrag;
  37192. private _pickWithRayOnDragPlane;
  37193. private _pointA;
  37194. private _pointB;
  37195. private _pointC;
  37196. private _lineA;
  37197. private _lineB;
  37198. private _localAxis;
  37199. private _lookAt;
  37200. private _updateDragPlanePosition;
  37201. /**
  37202. * Detaches the behavior from the mesh
  37203. */
  37204. detach(): void;
  37205. }
  37206. }
  37207. declare module BABYLON {
  37208. /**
  37209. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37210. */
  37211. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37212. private _dragBehaviorA;
  37213. private _dragBehaviorB;
  37214. private _startDistance;
  37215. private _initialScale;
  37216. private _targetScale;
  37217. private _ownerNode;
  37218. private _sceneRenderObserver;
  37219. /**
  37220. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37221. */
  37222. constructor();
  37223. /**
  37224. * The name of the behavior
  37225. */
  37226. readonly name: string;
  37227. /**
  37228. * Initializes the behavior
  37229. */
  37230. init(): void;
  37231. private _getCurrentDistance;
  37232. /**
  37233. * Attaches the scale behavior the passed in mesh
  37234. * @param ownerNode The mesh that will be scaled around once attached
  37235. */
  37236. attach(ownerNode: Mesh): void;
  37237. /**
  37238. * Detaches the behavior from the mesh
  37239. */
  37240. detach(): void;
  37241. }
  37242. }
  37243. declare module BABYLON {
  37244. /**
  37245. * 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
  37246. */
  37247. export class SixDofDragBehavior implements Behavior<Mesh> {
  37248. private static _virtualScene;
  37249. private _ownerNode;
  37250. private _sceneRenderObserver;
  37251. private _scene;
  37252. private _targetPosition;
  37253. private _virtualOriginMesh;
  37254. private _virtualDragMesh;
  37255. private _pointerObserver;
  37256. private _moving;
  37257. private _startingOrientation;
  37258. /**
  37259. * 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)
  37260. */
  37261. private zDragFactor;
  37262. /**
  37263. * If the object should rotate to face the drag origin
  37264. */
  37265. rotateDraggedObject: boolean;
  37266. /**
  37267. * If the behavior is currently in a dragging state
  37268. */
  37269. dragging: boolean;
  37270. /**
  37271. * 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)
  37272. */
  37273. dragDeltaRatio: number;
  37274. /**
  37275. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37276. */
  37277. currentDraggingPointerID: number;
  37278. /**
  37279. * If camera controls should be detached during the drag
  37280. */
  37281. detachCameraControls: boolean;
  37282. /**
  37283. * Fires each time a drag starts
  37284. */
  37285. onDragStartObservable: Observable<{}>;
  37286. /**
  37287. * Fires each time a drag ends (eg. mouse release after drag)
  37288. */
  37289. onDragEndObservable: Observable<{}>;
  37290. /**
  37291. * 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
  37292. */
  37293. constructor();
  37294. /**
  37295. * The name of the behavior
  37296. */
  37297. readonly name: string;
  37298. /**
  37299. * Initializes the behavior
  37300. */
  37301. init(): void;
  37302. /**
  37303. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37304. */
  37305. private readonly _pointerCamera;
  37306. /**
  37307. * Attaches the scale behavior the passed in mesh
  37308. * @param ownerNode The mesh that will be scaled around once attached
  37309. */
  37310. attach(ownerNode: Mesh): void;
  37311. /**
  37312. * Detaches the behavior from the mesh
  37313. */
  37314. detach(): void;
  37315. }
  37316. }
  37317. declare module BABYLON {
  37318. /**
  37319. * Class used to apply inverse kinematics to bones
  37320. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37321. */
  37322. export class BoneIKController {
  37323. private static _tmpVecs;
  37324. private static _tmpQuat;
  37325. private static _tmpMats;
  37326. /**
  37327. * Gets or sets the target mesh
  37328. */
  37329. targetMesh: AbstractMesh;
  37330. /** Gets or sets the mesh used as pole */
  37331. poleTargetMesh: AbstractMesh;
  37332. /**
  37333. * Gets or sets the bone used as pole
  37334. */
  37335. poleTargetBone: Nullable<Bone>;
  37336. /**
  37337. * Gets or sets the target position
  37338. */
  37339. targetPosition: Vector3;
  37340. /**
  37341. * Gets or sets the pole target position
  37342. */
  37343. poleTargetPosition: Vector3;
  37344. /**
  37345. * Gets or sets the pole target local offset
  37346. */
  37347. poleTargetLocalOffset: Vector3;
  37348. /**
  37349. * Gets or sets the pole angle
  37350. */
  37351. poleAngle: number;
  37352. /**
  37353. * Gets or sets the mesh associated with the controller
  37354. */
  37355. mesh: AbstractMesh;
  37356. /**
  37357. * 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)
  37358. */
  37359. slerpAmount: number;
  37360. private _bone1Quat;
  37361. private _bone1Mat;
  37362. private _bone2Ang;
  37363. private _bone1;
  37364. private _bone2;
  37365. private _bone1Length;
  37366. private _bone2Length;
  37367. private _maxAngle;
  37368. private _maxReach;
  37369. private _rightHandedSystem;
  37370. private _bendAxis;
  37371. private _slerping;
  37372. private _adjustRoll;
  37373. /**
  37374. * Gets or sets maximum allowed angle
  37375. */
  37376. maxAngle: number;
  37377. /**
  37378. * Creates a new BoneIKController
  37379. * @param mesh defines the mesh to control
  37380. * @param bone defines the bone to control
  37381. * @param options defines options to set up the controller
  37382. */
  37383. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37384. targetMesh?: AbstractMesh;
  37385. poleTargetMesh?: AbstractMesh;
  37386. poleTargetBone?: Bone;
  37387. poleTargetLocalOffset?: Vector3;
  37388. poleAngle?: number;
  37389. bendAxis?: Vector3;
  37390. maxAngle?: number;
  37391. slerpAmount?: number;
  37392. });
  37393. private _setMaxAngle;
  37394. /**
  37395. * Force the controller to update the bones
  37396. */
  37397. update(): void;
  37398. }
  37399. }
  37400. declare module BABYLON {
  37401. /**
  37402. * Class used to make a bone look toward a point in space
  37403. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37404. */
  37405. export class BoneLookController {
  37406. private static _tmpVecs;
  37407. private static _tmpQuat;
  37408. private static _tmpMats;
  37409. /**
  37410. * The target Vector3 that the bone will look at
  37411. */
  37412. target: Vector3;
  37413. /**
  37414. * The mesh that the bone is attached to
  37415. */
  37416. mesh: AbstractMesh;
  37417. /**
  37418. * The bone that will be looking to the target
  37419. */
  37420. bone: Bone;
  37421. /**
  37422. * The up axis of the coordinate system that is used when the bone is rotated
  37423. */
  37424. upAxis: Vector3;
  37425. /**
  37426. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37427. */
  37428. upAxisSpace: Space;
  37429. /**
  37430. * Used to make an adjustment to the yaw of the bone
  37431. */
  37432. adjustYaw: number;
  37433. /**
  37434. * Used to make an adjustment to the pitch of the bone
  37435. */
  37436. adjustPitch: number;
  37437. /**
  37438. * Used to make an adjustment to the roll of the bone
  37439. */
  37440. adjustRoll: number;
  37441. /**
  37442. * 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)
  37443. */
  37444. slerpAmount: number;
  37445. private _minYaw;
  37446. private _maxYaw;
  37447. private _minPitch;
  37448. private _maxPitch;
  37449. private _minYawSin;
  37450. private _minYawCos;
  37451. private _maxYawSin;
  37452. private _maxYawCos;
  37453. private _midYawConstraint;
  37454. private _minPitchTan;
  37455. private _maxPitchTan;
  37456. private _boneQuat;
  37457. private _slerping;
  37458. private _transformYawPitch;
  37459. private _transformYawPitchInv;
  37460. private _firstFrameSkipped;
  37461. private _yawRange;
  37462. private _fowardAxis;
  37463. /**
  37464. * Gets or sets the minimum yaw angle that the bone can look to
  37465. */
  37466. minYaw: number;
  37467. /**
  37468. * Gets or sets the maximum yaw angle that the bone can look to
  37469. */
  37470. maxYaw: number;
  37471. /**
  37472. * Gets or sets the minimum pitch angle that the bone can look to
  37473. */
  37474. minPitch: number;
  37475. /**
  37476. * Gets or sets the maximum pitch angle that the bone can look to
  37477. */
  37478. maxPitch: number;
  37479. /**
  37480. * Create a BoneLookController
  37481. * @param mesh the mesh that the bone belongs to
  37482. * @param bone the bone that will be looking to the target
  37483. * @param target the target Vector3 to look at
  37484. * @param options optional settings:
  37485. * * maxYaw: the maximum angle the bone will yaw to
  37486. * * minYaw: the minimum angle the bone will yaw to
  37487. * * maxPitch: the maximum angle the bone will pitch to
  37488. * * minPitch: the minimum angle the bone will yaw to
  37489. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37490. * * upAxis: the up axis of the coordinate system
  37491. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37492. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37493. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37494. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37495. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37496. * * adjustRoll: used to make an adjustment to the roll of the bone
  37497. **/
  37498. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37499. maxYaw?: number;
  37500. minYaw?: number;
  37501. maxPitch?: number;
  37502. minPitch?: number;
  37503. slerpAmount?: number;
  37504. upAxis?: Vector3;
  37505. upAxisSpace?: Space;
  37506. yawAxis?: Vector3;
  37507. pitchAxis?: Vector3;
  37508. adjustYaw?: number;
  37509. adjustPitch?: number;
  37510. adjustRoll?: number;
  37511. });
  37512. /**
  37513. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37514. */
  37515. update(): void;
  37516. private _getAngleDiff;
  37517. private _getAngleBetween;
  37518. private _isAngleBetween;
  37519. }
  37520. }
  37521. declare module BABYLON {
  37522. /**
  37523. * Manage the gamepad inputs to control an arc rotate camera.
  37524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37525. */
  37526. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37527. /**
  37528. * Defines the camera the input is attached to.
  37529. */
  37530. camera: ArcRotateCamera;
  37531. /**
  37532. * Defines the gamepad the input is gathering event from.
  37533. */
  37534. gamepad: Nullable<Gamepad>;
  37535. /**
  37536. * Defines the gamepad rotation sensiblity.
  37537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37538. */
  37539. gamepadRotationSensibility: number;
  37540. /**
  37541. * Defines the gamepad move sensiblity.
  37542. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37543. */
  37544. gamepadMoveSensibility: number;
  37545. private _yAxisScale;
  37546. /**
  37547. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37548. */
  37549. invertYAxis: boolean;
  37550. private _onGamepadConnectedObserver;
  37551. private _onGamepadDisconnectedObserver;
  37552. /**
  37553. * Attach the input controls to a specific dom element to get the input from.
  37554. * @param element Defines the element the controls should be listened from
  37555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37556. */
  37557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37558. /**
  37559. * Detach the current controls from the specified dom element.
  37560. * @param element Defines the element to stop listening the inputs from
  37561. */
  37562. detachControl(element: Nullable<HTMLElement>): void;
  37563. /**
  37564. * Update the current camera state depending on the inputs that have been used this frame.
  37565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37566. */
  37567. checkInputs(): void;
  37568. /**
  37569. * Gets the class name of the current intput.
  37570. * @returns the class name
  37571. */
  37572. getClassName(): string;
  37573. /**
  37574. * Get the friendly name associated with the input class.
  37575. * @returns the input friendly name
  37576. */
  37577. getSimpleName(): string;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. interface ArcRotateCameraInputsManager {
  37582. /**
  37583. * Add orientation input support to the input manager.
  37584. * @returns the current input manager
  37585. */
  37586. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37587. }
  37588. /**
  37589. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37591. */
  37592. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37593. /**
  37594. * Defines the camera the input is attached to.
  37595. */
  37596. camera: ArcRotateCamera;
  37597. /**
  37598. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37599. */
  37600. alphaCorrection: number;
  37601. /**
  37602. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37603. */
  37604. gammaCorrection: number;
  37605. private _alpha;
  37606. private _gamma;
  37607. private _dirty;
  37608. private _deviceOrientationHandler;
  37609. /**
  37610. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37611. */
  37612. constructor();
  37613. /**
  37614. * Attach the input controls to a specific dom element to get the input from.
  37615. * @param element Defines the element the controls should be listened from
  37616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37617. */
  37618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37619. /** @hidden */
  37620. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37621. /**
  37622. * Update the current camera state depending on the inputs that have been used this frame.
  37623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37624. */
  37625. checkInputs(): void;
  37626. /**
  37627. * Detach the current controls from the specified dom element.
  37628. * @param element Defines the element to stop listening the inputs from
  37629. */
  37630. detachControl(element: Nullable<HTMLElement>): void;
  37631. /**
  37632. * Gets the class name of the current intput.
  37633. * @returns the class name
  37634. */
  37635. getClassName(): string;
  37636. /**
  37637. * Get the friendly name associated with the input class.
  37638. * @returns the input friendly name
  37639. */
  37640. getSimpleName(): string;
  37641. }
  37642. }
  37643. declare module BABYLON {
  37644. /**
  37645. * Listen to mouse events to control the camera.
  37646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37647. */
  37648. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37649. /**
  37650. * Defines the camera the input is attached to.
  37651. */
  37652. camera: FlyCamera;
  37653. /**
  37654. * Defines if touch is enabled. (Default is true.)
  37655. */
  37656. touchEnabled: boolean;
  37657. /**
  37658. * Defines the buttons associated with the input to handle camera rotation.
  37659. */
  37660. buttons: number[];
  37661. /**
  37662. * Assign buttons for Yaw control.
  37663. */
  37664. buttonsYaw: number[];
  37665. /**
  37666. * Assign buttons for Pitch control.
  37667. */
  37668. buttonsPitch: number[];
  37669. /**
  37670. * Assign buttons for Roll control.
  37671. */
  37672. buttonsRoll: number[];
  37673. /**
  37674. * Detect if any button is being pressed while mouse is moved.
  37675. * -1 = Mouse locked.
  37676. * 0 = Left button.
  37677. * 1 = Middle Button.
  37678. * 2 = Right Button.
  37679. */
  37680. activeButton: number;
  37681. /**
  37682. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37683. * Higher values reduce its sensitivity.
  37684. */
  37685. angularSensibility: number;
  37686. private _mousemoveCallback;
  37687. private _observer;
  37688. private _rollObserver;
  37689. private previousPosition;
  37690. private noPreventDefault;
  37691. private element;
  37692. /**
  37693. * Listen to mouse events to control the camera.
  37694. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37696. */
  37697. constructor(touchEnabled?: boolean);
  37698. /**
  37699. * Attach the mouse control to the HTML DOM element.
  37700. * @param element Defines the element that listens to the input events.
  37701. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37702. */
  37703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37704. /**
  37705. * Detach the current controls from the specified dom element.
  37706. * @param element Defines the element to stop listening the inputs from
  37707. */
  37708. detachControl(element: Nullable<HTMLElement>): void;
  37709. /**
  37710. * Gets the class name of the current input.
  37711. * @returns the class name.
  37712. */
  37713. getClassName(): string;
  37714. /**
  37715. * Get the friendly name associated with the input class.
  37716. * @returns the input's friendly name.
  37717. */
  37718. getSimpleName(): string;
  37719. private _pointerInput;
  37720. private _onMouseMove;
  37721. /**
  37722. * Rotate camera by mouse offset.
  37723. */
  37724. private rotateCamera;
  37725. }
  37726. }
  37727. declare module BABYLON {
  37728. /**
  37729. * Default Inputs manager for the FlyCamera.
  37730. * It groups all the default supported inputs for ease of use.
  37731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37732. */
  37733. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37734. /**
  37735. * Instantiates a new FlyCameraInputsManager.
  37736. * @param camera Defines the camera the inputs belong to.
  37737. */
  37738. constructor(camera: FlyCamera);
  37739. /**
  37740. * Add keyboard input support to the input manager.
  37741. * @returns the new FlyCameraKeyboardMoveInput().
  37742. */
  37743. addKeyboard(): FlyCameraInputsManager;
  37744. /**
  37745. * Add mouse input support to the input manager.
  37746. * @param touchEnabled Enable touch screen support.
  37747. * @returns the new FlyCameraMouseInput().
  37748. */
  37749. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37750. }
  37751. }
  37752. declare module BABYLON {
  37753. /**
  37754. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37755. * such as in a 3D Space Shooter or a Flight Simulator.
  37756. */
  37757. export class FlyCamera extends TargetCamera {
  37758. /**
  37759. * Define the collision ellipsoid of the camera.
  37760. * This is helpful for simulating a camera body, like a player's body.
  37761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37762. */
  37763. ellipsoid: Vector3;
  37764. /**
  37765. * Define an offset for the position of the ellipsoid around the camera.
  37766. * This can be helpful if the camera is attached away from the player's body center,
  37767. * such as at its head.
  37768. */
  37769. ellipsoidOffset: Vector3;
  37770. /**
  37771. * Enable or disable collisions of the camera with the rest of the scene objects.
  37772. */
  37773. checkCollisions: boolean;
  37774. /**
  37775. * Enable or disable gravity on the camera.
  37776. */
  37777. applyGravity: boolean;
  37778. /**
  37779. * Define the current direction the camera is moving to.
  37780. */
  37781. cameraDirection: Vector3;
  37782. /**
  37783. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37784. * This overrides and empties cameraRotation.
  37785. */
  37786. rotationQuaternion: Quaternion;
  37787. /**
  37788. * Track Roll to maintain the wanted Rolling when looking around.
  37789. */
  37790. _trackRoll: number;
  37791. /**
  37792. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37793. */
  37794. rollCorrect: number;
  37795. /**
  37796. * Mimic a banked turn, Rolling the camera when Yawing.
  37797. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37798. */
  37799. bankedTurn: boolean;
  37800. /**
  37801. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37802. */
  37803. bankedTurnLimit: number;
  37804. /**
  37805. * Value of 0 disables the banked Roll.
  37806. * Value of 1 is equal to the Yaw angle in radians.
  37807. */
  37808. bankedTurnMultiplier: number;
  37809. /**
  37810. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37811. */
  37812. inputs: FlyCameraInputsManager;
  37813. /**
  37814. * Gets the input sensibility for mouse input.
  37815. * Higher values reduce sensitivity.
  37816. */
  37817. /**
  37818. * Sets the input sensibility for a mouse input.
  37819. * Higher values reduce sensitivity.
  37820. */
  37821. angularSensibility: number;
  37822. /**
  37823. * Get the keys for camera movement forward.
  37824. */
  37825. /**
  37826. * Set the keys for camera movement forward.
  37827. */
  37828. keysForward: number[];
  37829. /**
  37830. * Get the keys for camera movement backward.
  37831. */
  37832. keysBackward: number[];
  37833. /**
  37834. * Get the keys for camera movement up.
  37835. */
  37836. /**
  37837. * Set the keys for camera movement up.
  37838. */
  37839. keysUp: number[];
  37840. /**
  37841. * Get the keys for camera movement down.
  37842. */
  37843. /**
  37844. * Set the keys for camera movement down.
  37845. */
  37846. keysDown: number[];
  37847. /**
  37848. * Get the keys for camera movement left.
  37849. */
  37850. /**
  37851. * Set the keys for camera movement left.
  37852. */
  37853. keysLeft: number[];
  37854. /**
  37855. * Set the keys for camera movement right.
  37856. */
  37857. /**
  37858. * Set the keys for camera movement right.
  37859. */
  37860. keysRight: number[];
  37861. /**
  37862. * Event raised when the camera collides with a mesh in the scene.
  37863. */
  37864. onCollide: (collidedMesh: AbstractMesh) => void;
  37865. private _collider;
  37866. private _needMoveForGravity;
  37867. private _oldPosition;
  37868. private _diffPosition;
  37869. private _newPosition;
  37870. /** @hidden */
  37871. _localDirection: Vector3;
  37872. /** @hidden */
  37873. _transformedDirection: Vector3;
  37874. /**
  37875. * Instantiates a FlyCamera.
  37876. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37877. * such as in a 3D Space Shooter or a Flight Simulator.
  37878. * @param name Define the name of the camera in the scene.
  37879. * @param position Define the starting position of the camera in the scene.
  37880. * @param scene Define the scene the camera belongs to.
  37881. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37882. */
  37883. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37884. /**
  37885. * Attach a control to the HTML DOM element.
  37886. * @param element Defines the element that listens to the input events.
  37887. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37888. */
  37889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37890. /**
  37891. * Detach a control from the HTML DOM element.
  37892. * The camera will stop reacting to that input.
  37893. * @param element Defines the element that listens to the input events.
  37894. */
  37895. detachControl(element: HTMLElement): void;
  37896. private _collisionMask;
  37897. /**
  37898. * Get the mask that the camera ignores in collision events.
  37899. */
  37900. /**
  37901. * Set the mask that the camera ignores in collision events.
  37902. */
  37903. collisionMask: number;
  37904. /** @hidden */
  37905. _collideWithWorld(displacement: Vector3): void;
  37906. /** @hidden */
  37907. private _onCollisionPositionChange;
  37908. /** @hidden */
  37909. _checkInputs(): void;
  37910. /** @hidden */
  37911. _decideIfNeedsToMove(): boolean;
  37912. /** @hidden */
  37913. _updatePosition(): void;
  37914. /**
  37915. * Restore the Roll to its target value at the rate specified.
  37916. * @param rate - Higher means slower restoring.
  37917. * @hidden
  37918. */
  37919. restoreRoll(rate: number): void;
  37920. /**
  37921. * Destroy the camera and release the current resources held by it.
  37922. */
  37923. dispose(): void;
  37924. /**
  37925. * Get the current object class name.
  37926. * @returns the class name.
  37927. */
  37928. getClassName(): string;
  37929. }
  37930. }
  37931. declare module BABYLON {
  37932. /**
  37933. * Listen to keyboard events to control the camera.
  37934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37935. */
  37936. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37937. /**
  37938. * Defines the camera the input is attached to.
  37939. */
  37940. camera: FlyCamera;
  37941. /**
  37942. * The list of keyboard keys used to control the forward move of the camera.
  37943. */
  37944. keysForward: number[];
  37945. /**
  37946. * The list of keyboard keys used to control the backward move of the camera.
  37947. */
  37948. keysBackward: number[];
  37949. /**
  37950. * The list of keyboard keys used to control the forward move of the camera.
  37951. */
  37952. keysUp: number[];
  37953. /**
  37954. * The list of keyboard keys used to control the backward move of the camera.
  37955. */
  37956. keysDown: number[];
  37957. /**
  37958. * The list of keyboard keys used to control the right strafe move of the camera.
  37959. */
  37960. keysRight: number[];
  37961. /**
  37962. * The list of keyboard keys used to control the left strafe move of the camera.
  37963. */
  37964. keysLeft: number[];
  37965. private _keys;
  37966. private _onCanvasBlurObserver;
  37967. private _onKeyboardObserver;
  37968. private _engine;
  37969. private _scene;
  37970. /**
  37971. * Attach the input controls to a specific dom element to get the input from.
  37972. * @param element Defines the element the controls should be listened from
  37973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37974. */
  37975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37976. /**
  37977. * Detach the current controls from the specified dom element.
  37978. * @param element Defines the element to stop listening the inputs from
  37979. */
  37980. detachControl(element: Nullable<HTMLElement>): void;
  37981. /**
  37982. * Gets the class name of the current intput.
  37983. * @returns the class name
  37984. */
  37985. getClassName(): string;
  37986. /** @hidden */
  37987. _onLostFocus(e: FocusEvent): void;
  37988. /**
  37989. * Get the friendly name associated with the input class.
  37990. * @returns the input friendly name
  37991. */
  37992. getSimpleName(): string;
  37993. /**
  37994. * Update the current camera state depending on the inputs that have been used this frame.
  37995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37996. */
  37997. checkInputs(): void;
  37998. }
  37999. }
  38000. declare module BABYLON {
  38001. /**
  38002. * Manage the mouse wheel inputs to control a follow camera.
  38003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38004. */
  38005. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38006. /**
  38007. * Defines the camera the input is attached to.
  38008. */
  38009. camera: FollowCamera;
  38010. /**
  38011. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38012. */
  38013. axisControlRadius: boolean;
  38014. /**
  38015. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38016. */
  38017. axisControlHeight: boolean;
  38018. /**
  38019. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38020. */
  38021. axisControlRotation: boolean;
  38022. /**
  38023. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38024. * relation to mouseWheel events.
  38025. */
  38026. wheelPrecision: number;
  38027. /**
  38028. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38029. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38030. */
  38031. wheelDeltaPercentage: number;
  38032. private _wheel;
  38033. private _observer;
  38034. /**
  38035. * Attach the input controls to a specific dom element to get the input from.
  38036. * @param element Defines the element the controls should be listened from
  38037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38038. */
  38039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38040. /**
  38041. * Detach the current controls from the specified dom element.
  38042. * @param element Defines the element to stop listening the inputs from
  38043. */
  38044. detachControl(element: Nullable<HTMLElement>): void;
  38045. /**
  38046. * Gets the class name of the current intput.
  38047. * @returns the class name
  38048. */
  38049. getClassName(): string;
  38050. /**
  38051. * Get the friendly name associated with the input class.
  38052. * @returns the input friendly name
  38053. */
  38054. getSimpleName(): string;
  38055. }
  38056. }
  38057. declare module BABYLON {
  38058. /**
  38059. * Manage the pointers inputs to control an follow camera.
  38060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38061. */
  38062. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38063. /**
  38064. * Defines the camera the input is attached to.
  38065. */
  38066. camera: FollowCamera;
  38067. /**
  38068. * Gets the class name of the current input.
  38069. * @returns the class name
  38070. */
  38071. getClassName(): string;
  38072. /**
  38073. * Defines the pointer angular sensibility along the X axis or how fast is
  38074. * the camera rotating.
  38075. * A negative number will reverse the axis direction.
  38076. */
  38077. angularSensibilityX: number;
  38078. /**
  38079. * Defines the pointer angular sensibility along the Y axis or how fast is
  38080. * the camera rotating.
  38081. * A negative number will reverse the axis direction.
  38082. */
  38083. angularSensibilityY: number;
  38084. /**
  38085. * Defines the pointer pinch precision or how fast is the camera zooming.
  38086. * A negative number will reverse the axis direction.
  38087. */
  38088. pinchPrecision: number;
  38089. /**
  38090. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38091. * from 0.
  38092. * It defines the percentage of current camera.radius to use as delta when
  38093. * pinch zoom is used.
  38094. */
  38095. pinchDeltaPercentage: number;
  38096. /**
  38097. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38098. */
  38099. axisXControlRadius: boolean;
  38100. /**
  38101. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38102. */
  38103. axisXControlHeight: boolean;
  38104. /**
  38105. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38106. */
  38107. axisXControlRotation: boolean;
  38108. /**
  38109. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38110. */
  38111. axisYControlRadius: boolean;
  38112. /**
  38113. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38114. */
  38115. axisYControlHeight: boolean;
  38116. /**
  38117. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38118. */
  38119. axisYControlRotation: boolean;
  38120. /**
  38121. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38122. */
  38123. axisPinchControlRadius: boolean;
  38124. /**
  38125. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38126. */
  38127. axisPinchControlHeight: boolean;
  38128. /**
  38129. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38130. */
  38131. axisPinchControlRotation: boolean;
  38132. /**
  38133. * Log error messages if basic misconfiguration has occurred.
  38134. */
  38135. warningEnable: boolean;
  38136. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38137. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38138. private _warningCounter;
  38139. private _warning;
  38140. }
  38141. }
  38142. declare module BABYLON {
  38143. /**
  38144. * Default Inputs manager for the FollowCamera.
  38145. * It groups all the default supported inputs for ease of use.
  38146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38147. */
  38148. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38149. /**
  38150. * Instantiates a new FollowCameraInputsManager.
  38151. * @param camera Defines the camera the inputs belong to
  38152. */
  38153. constructor(camera: FollowCamera);
  38154. /**
  38155. * Add keyboard input support to the input manager.
  38156. * @returns the current input manager
  38157. */
  38158. addKeyboard(): FollowCameraInputsManager;
  38159. /**
  38160. * Add mouse wheel input support to the input manager.
  38161. * @returns the current input manager
  38162. */
  38163. addMouseWheel(): FollowCameraInputsManager;
  38164. /**
  38165. * Add pointers input support to the input manager.
  38166. * @returns the current input manager
  38167. */
  38168. addPointers(): FollowCameraInputsManager;
  38169. /**
  38170. * Add orientation input support to the input manager.
  38171. * @returns the current input manager
  38172. */
  38173. addVRDeviceOrientation(): FollowCameraInputsManager;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. /**
  38178. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38179. * an arc rotate version arcFollowCamera are available.
  38180. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38181. */
  38182. export class FollowCamera extends TargetCamera {
  38183. /**
  38184. * Distance the follow camera should follow an object at
  38185. */
  38186. radius: number;
  38187. /**
  38188. * Minimum allowed distance of the camera to the axis of rotation
  38189. * (The camera can not get closer).
  38190. * This can help limiting how the Camera is able to move in the scene.
  38191. */
  38192. lowerRadiusLimit: Nullable<number>;
  38193. /**
  38194. * Maximum allowed distance of the camera to the axis of rotation
  38195. * (The camera can not get further).
  38196. * This can help limiting how the Camera is able to move in the scene.
  38197. */
  38198. upperRadiusLimit: Nullable<number>;
  38199. /**
  38200. * Define a rotation offset between the camera and the object it follows
  38201. */
  38202. rotationOffset: number;
  38203. /**
  38204. * Minimum allowed angle to camera position relative to target object.
  38205. * This can help limiting how the Camera is able to move in the scene.
  38206. */
  38207. lowerRotationOffsetLimit: Nullable<number>;
  38208. /**
  38209. * Maximum allowed angle to camera position relative to target object.
  38210. * This can help limiting how the Camera is able to move in the scene.
  38211. */
  38212. upperRotationOffsetLimit: Nullable<number>;
  38213. /**
  38214. * Define a height offset between the camera and the object it follows.
  38215. * It can help following an object from the top (like a car chaing a plane)
  38216. */
  38217. heightOffset: number;
  38218. /**
  38219. * Minimum allowed height of camera position relative to target object.
  38220. * This can help limiting how the Camera is able to move in the scene.
  38221. */
  38222. lowerHeightOffsetLimit: Nullable<number>;
  38223. /**
  38224. * Maximum allowed height of camera position relative to target object.
  38225. * This can help limiting how the Camera is able to move in the scene.
  38226. */
  38227. upperHeightOffsetLimit: Nullable<number>;
  38228. /**
  38229. * Define how fast the camera can accelerate to follow it s target.
  38230. */
  38231. cameraAcceleration: number;
  38232. /**
  38233. * Define the speed limit of the camera following an object.
  38234. */
  38235. maxCameraSpeed: number;
  38236. /**
  38237. * Define the target of the camera.
  38238. */
  38239. lockedTarget: Nullable<AbstractMesh>;
  38240. /**
  38241. * Defines the input associated with the camera.
  38242. */
  38243. inputs: FollowCameraInputsManager;
  38244. /**
  38245. * Instantiates the follow camera.
  38246. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38247. * @param name Define the name of the camera in the scene
  38248. * @param position Define the position of the camera
  38249. * @param scene Define the scene the camera belong to
  38250. * @param lockedTarget Define the target of the camera
  38251. */
  38252. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38253. private _follow;
  38254. /**
  38255. * Attached controls to the current camera.
  38256. * @param element Defines the element the controls should be listened from
  38257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38258. */
  38259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38260. /**
  38261. * Detach the current controls from the camera.
  38262. * The camera will stop reacting to inputs.
  38263. * @param element Defines the element to stop listening the inputs from
  38264. */
  38265. detachControl(element: HTMLElement): void;
  38266. /** @hidden */
  38267. _checkInputs(): void;
  38268. private _checkLimits;
  38269. /**
  38270. * Gets the camera class name.
  38271. * @returns the class name
  38272. */
  38273. getClassName(): string;
  38274. }
  38275. /**
  38276. * Arc Rotate version of the follow camera.
  38277. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38278. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38279. */
  38280. export class ArcFollowCamera extends TargetCamera {
  38281. /** The longitudinal angle of the camera */
  38282. alpha: number;
  38283. /** The latitudinal angle of the camera */
  38284. beta: number;
  38285. /** The radius of the camera from its target */
  38286. radius: number;
  38287. /** Define the camera target (the messh it should follow) */
  38288. target: Nullable<AbstractMesh>;
  38289. private _cartesianCoordinates;
  38290. /**
  38291. * Instantiates a new ArcFollowCamera
  38292. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38293. * @param name Define the name of the camera
  38294. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38295. * @param beta Define the rotation angle of the camera around the elevation axis
  38296. * @param radius Define the radius of the camera from its target point
  38297. * @param target Define the target of the camera
  38298. * @param scene Define the scene the camera belongs to
  38299. */
  38300. constructor(name: string,
  38301. /** The longitudinal angle of the camera */
  38302. alpha: number,
  38303. /** The latitudinal angle of the camera */
  38304. beta: number,
  38305. /** The radius of the camera from its target */
  38306. radius: number,
  38307. /** Define the camera target (the messh it should follow) */
  38308. target: Nullable<AbstractMesh>, scene: Scene);
  38309. private _follow;
  38310. /** @hidden */
  38311. _checkInputs(): void;
  38312. /**
  38313. * Returns the class name of the object.
  38314. * It is mostly used internally for serialization purposes.
  38315. */
  38316. getClassName(): string;
  38317. }
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * Manage the keyboard inputs to control the movement of a follow camera.
  38322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38323. */
  38324. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38325. /**
  38326. * Defines the camera the input is attached to.
  38327. */
  38328. camera: FollowCamera;
  38329. /**
  38330. * Defines the list of key codes associated with the up action (increase heightOffset)
  38331. */
  38332. keysHeightOffsetIncr: number[];
  38333. /**
  38334. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38335. */
  38336. keysHeightOffsetDecr: number[];
  38337. /**
  38338. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38339. */
  38340. keysHeightOffsetModifierAlt: boolean;
  38341. /**
  38342. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38343. */
  38344. keysHeightOffsetModifierCtrl: boolean;
  38345. /**
  38346. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38347. */
  38348. keysHeightOffsetModifierShift: boolean;
  38349. /**
  38350. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38351. */
  38352. keysRotationOffsetIncr: number[];
  38353. /**
  38354. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38355. */
  38356. keysRotationOffsetDecr: number[];
  38357. /**
  38358. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38359. */
  38360. keysRotationOffsetModifierAlt: boolean;
  38361. /**
  38362. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38363. */
  38364. keysRotationOffsetModifierCtrl: boolean;
  38365. /**
  38366. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38367. */
  38368. keysRotationOffsetModifierShift: boolean;
  38369. /**
  38370. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38371. */
  38372. keysRadiusIncr: number[];
  38373. /**
  38374. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38375. */
  38376. keysRadiusDecr: number[];
  38377. /**
  38378. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38379. */
  38380. keysRadiusModifierAlt: boolean;
  38381. /**
  38382. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38383. */
  38384. keysRadiusModifierCtrl: boolean;
  38385. /**
  38386. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38387. */
  38388. keysRadiusModifierShift: boolean;
  38389. /**
  38390. * Defines the rate of change of heightOffset.
  38391. */
  38392. heightSensibility: number;
  38393. /**
  38394. * Defines the rate of change of rotationOffset.
  38395. */
  38396. rotationSensibility: number;
  38397. /**
  38398. * Defines the rate of change of radius.
  38399. */
  38400. radiusSensibility: number;
  38401. private _keys;
  38402. private _ctrlPressed;
  38403. private _altPressed;
  38404. private _shiftPressed;
  38405. private _onCanvasBlurObserver;
  38406. private _onKeyboardObserver;
  38407. private _engine;
  38408. private _scene;
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /**
  38416. * Detach the current controls from the specified dom element.
  38417. * @param element Defines the element to stop listening the inputs from
  38418. */
  38419. detachControl(element: Nullable<HTMLElement>): void;
  38420. /**
  38421. * Update the current camera state depending on the inputs that have been used this frame.
  38422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38423. */
  38424. checkInputs(): void;
  38425. /**
  38426. * Gets the class name of the current input.
  38427. * @returns the class name
  38428. */
  38429. getClassName(): string;
  38430. /**
  38431. * Get the friendly name associated with the input class.
  38432. * @returns the input friendly name
  38433. */
  38434. getSimpleName(): string;
  38435. /**
  38436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38437. * allow modification of the heightOffset value.
  38438. */
  38439. private _modifierHeightOffset;
  38440. /**
  38441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38442. * allow modification of the rotationOffset value.
  38443. */
  38444. private _modifierRotationOffset;
  38445. /**
  38446. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38447. * allow modification of the radius value.
  38448. */
  38449. private _modifierRadius;
  38450. }
  38451. }
  38452. declare module BABYLON {
  38453. interface FreeCameraInputsManager {
  38454. /**
  38455. * @hidden
  38456. */
  38457. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38458. /**
  38459. * Add orientation input support to the input manager.
  38460. * @returns the current input manager
  38461. */
  38462. addDeviceOrientation(): FreeCameraInputsManager;
  38463. }
  38464. /**
  38465. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38466. * Screen rotation is taken into account.
  38467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38468. */
  38469. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38470. private _camera;
  38471. private _screenOrientationAngle;
  38472. private _constantTranform;
  38473. private _screenQuaternion;
  38474. private _alpha;
  38475. private _beta;
  38476. private _gamma;
  38477. /**
  38478. * Can be used to detect if a device orientation sensor is availible on a device
  38479. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38480. * @returns a promise that will resolve on orientation change
  38481. */
  38482. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38483. /**
  38484. * @hidden
  38485. */
  38486. _onDeviceOrientationChangedObservable: Observable<void>;
  38487. /**
  38488. * Instantiates a new input
  38489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38490. */
  38491. constructor();
  38492. /**
  38493. * Define the camera controlled by the input.
  38494. */
  38495. camera: FreeCamera;
  38496. /**
  38497. * Attach the input controls to a specific dom element to get the input from.
  38498. * @param element Defines the element the controls should be listened from
  38499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38500. */
  38501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38502. private _orientationChanged;
  38503. private _deviceOrientation;
  38504. /**
  38505. * Detach the current controls from the specified dom element.
  38506. * @param element Defines the element to stop listening the inputs from
  38507. */
  38508. detachControl(element: Nullable<HTMLElement>): void;
  38509. /**
  38510. * Update the current camera state depending on the inputs that have been used this frame.
  38511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38512. */
  38513. checkInputs(): void;
  38514. /**
  38515. * Gets the class name of the current intput.
  38516. * @returns the class name
  38517. */
  38518. getClassName(): string;
  38519. /**
  38520. * Get the friendly name associated with the input class.
  38521. * @returns the input friendly name
  38522. */
  38523. getSimpleName(): string;
  38524. }
  38525. }
  38526. declare module BABYLON {
  38527. /**
  38528. * Manage the gamepad inputs to control a free camera.
  38529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38530. */
  38531. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38532. /**
  38533. * Define the camera the input is attached to.
  38534. */
  38535. camera: FreeCamera;
  38536. /**
  38537. * Define the Gamepad controlling the input
  38538. */
  38539. gamepad: Nullable<Gamepad>;
  38540. /**
  38541. * Defines the gamepad rotation sensiblity.
  38542. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38543. */
  38544. gamepadAngularSensibility: number;
  38545. /**
  38546. * Defines the gamepad move sensiblity.
  38547. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38548. */
  38549. gamepadMoveSensibility: number;
  38550. private _yAxisScale;
  38551. /**
  38552. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38553. */
  38554. invertYAxis: boolean;
  38555. private _onGamepadConnectedObserver;
  38556. private _onGamepadDisconnectedObserver;
  38557. private _cameraTransform;
  38558. private _deltaTransform;
  38559. private _vector3;
  38560. private _vector2;
  38561. /**
  38562. * Attach the input controls to a specific dom element to get the input from.
  38563. * @param element Defines the element the controls should be listened from
  38564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38565. */
  38566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38567. /**
  38568. * Detach the current controls from the specified dom element.
  38569. * @param element Defines the element to stop listening the inputs from
  38570. */
  38571. detachControl(element: Nullable<HTMLElement>): void;
  38572. /**
  38573. * Update the current camera state depending on the inputs that have been used this frame.
  38574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38575. */
  38576. checkInputs(): void;
  38577. /**
  38578. * Gets the class name of the current intput.
  38579. * @returns the class name
  38580. */
  38581. getClassName(): string;
  38582. /**
  38583. * Get the friendly name associated with the input class.
  38584. * @returns the input friendly name
  38585. */
  38586. getSimpleName(): string;
  38587. }
  38588. }
  38589. declare module BABYLON {
  38590. /**
  38591. * Defines the potential axis of a Joystick
  38592. */
  38593. export enum JoystickAxis {
  38594. /** X axis */
  38595. X = 0,
  38596. /** Y axis */
  38597. Y = 1,
  38598. /** Z axis */
  38599. Z = 2
  38600. }
  38601. /**
  38602. * Class used to define virtual joystick (used in touch mode)
  38603. */
  38604. export class VirtualJoystick {
  38605. /**
  38606. * Gets or sets a boolean indicating that left and right values must be inverted
  38607. */
  38608. reverseLeftRight: boolean;
  38609. /**
  38610. * Gets or sets a boolean indicating that up and down values must be inverted
  38611. */
  38612. reverseUpDown: boolean;
  38613. /**
  38614. * Gets the offset value for the position (ie. the change of the position value)
  38615. */
  38616. deltaPosition: Vector3;
  38617. /**
  38618. * Gets a boolean indicating if the virtual joystick was pressed
  38619. */
  38620. pressed: boolean;
  38621. /**
  38622. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38623. */
  38624. static Canvas: Nullable<HTMLCanvasElement>;
  38625. private static _globalJoystickIndex;
  38626. private static vjCanvasContext;
  38627. private static vjCanvasWidth;
  38628. private static vjCanvasHeight;
  38629. private static halfWidth;
  38630. private _action;
  38631. private _axisTargetedByLeftAndRight;
  38632. private _axisTargetedByUpAndDown;
  38633. private _joystickSensibility;
  38634. private _inversedSensibility;
  38635. private _joystickPointerID;
  38636. private _joystickColor;
  38637. private _joystickPointerPos;
  38638. private _joystickPreviousPointerPos;
  38639. private _joystickPointerStartPos;
  38640. private _deltaJoystickVector;
  38641. private _leftJoystick;
  38642. private _touches;
  38643. private _onPointerDownHandlerRef;
  38644. private _onPointerMoveHandlerRef;
  38645. private _onPointerUpHandlerRef;
  38646. private _onResize;
  38647. /**
  38648. * Creates a new virtual joystick
  38649. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38650. */
  38651. constructor(leftJoystick?: boolean);
  38652. /**
  38653. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38654. * @param newJoystickSensibility defines the new sensibility
  38655. */
  38656. setJoystickSensibility(newJoystickSensibility: number): void;
  38657. private _onPointerDown;
  38658. private _onPointerMove;
  38659. private _onPointerUp;
  38660. /**
  38661. * Change the color of the virtual joystick
  38662. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38663. */
  38664. setJoystickColor(newColor: string): void;
  38665. /**
  38666. * Defines a callback to call when the joystick is touched
  38667. * @param action defines the callback
  38668. */
  38669. setActionOnTouch(action: () => any): void;
  38670. /**
  38671. * Defines which axis you'd like to control for left & right
  38672. * @param axis defines the axis to use
  38673. */
  38674. setAxisForLeftRight(axis: JoystickAxis): void;
  38675. /**
  38676. * Defines which axis you'd like to control for up & down
  38677. * @param axis defines the axis to use
  38678. */
  38679. setAxisForUpDown(axis: JoystickAxis): void;
  38680. private _drawVirtualJoystick;
  38681. /**
  38682. * Release internal HTML canvas
  38683. */
  38684. releaseCanvas(): void;
  38685. }
  38686. }
  38687. declare module BABYLON {
  38688. interface FreeCameraInputsManager {
  38689. /**
  38690. * Add virtual joystick input support to the input manager.
  38691. * @returns the current input manager
  38692. */
  38693. addVirtualJoystick(): FreeCameraInputsManager;
  38694. }
  38695. /**
  38696. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38698. */
  38699. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38700. /**
  38701. * Defines the camera the input is attached to.
  38702. */
  38703. camera: FreeCamera;
  38704. private _leftjoystick;
  38705. private _rightjoystick;
  38706. /**
  38707. * Gets the left stick of the virtual joystick.
  38708. * @returns The virtual Joystick
  38709. */
  38710. getLeftJoystick(): VirtualJoystick;
  38711. /**
  38712. * Gets the right stick of the virtual joystick.
  38713. * @returns The virtual Joystick
  38714. */
  38715. getRightJoystick(): VirtualJoystick;
  38716. /**
  38717. * Update the current camera state depending on the inputs that have been used this frame.
  38718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38719. */
  38720. checkInputs(): void;
  38721. /**
  38722. * Attach the input controls to a specific dom element to get the input from.
  38723. * @param element Defines the element the controls should be listened from
  38724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38725. */
  38726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38727. /**
  38728. * Detach the current controls from the specified dom element.
  38729. * @param element Defines the element to stop listening the inputs from
  38730. */
  38731. detachControl(element: Nullable<HTMLElement>): void;
  38732. /**
  38733. * Gets the class name of the current intput.
  38734. * @returns the class name
  38735. */
  38736. getClassName(): string;
  38737. /**
  38738. * Get the friendly name associated with the input class.
  38739. * @returns the input friendly name
  38740. */
  38741. getSimpleName(): string;
  38742. }
  38743. }
  38744. declare module BABYLON {
  38745. /**
  38746. * This represents a FPS type of camera controlled by touch.
  38747. * This is like a universal camera minus the Gamepad controls.
  38748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38749. */
  38750. export class TouchCamera extends FreeCamera {
  38751. /**
  38752. * Defines the touch sensibility for rotation.
  38753. * The higher the faster.
  38754. */
  38755. touchAngularSensibility: number;
  38756. /**
  38757. * Defines the touch sensibility for move.
  38758. * The higher the faster.
  38759. */
  38760. touchMoveSensibility: number;
  38761. /**
  38762. * Instantiates a new touch camera.
  38763. * This represents a FPS type of camera controlled by touch.
  38764. * This is like a universal camera minus the Gamepad controls.
  38765. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38766. * @param name Define the name of the camera in the scene
  38767. * @param position Define the start position of the camera in the scene
  38768. * @param scene Define the scene the camera belongs to
  38769. */
  38770. constructor(name: string, position: Vector3, scene: Scene);
  38771. /**
  38772. * Gets the current object class name.
  38773. * @return the class name
  38774. */
  38775. getClassName(): string;
  38776. /** @hidden */
  38777. _setupInputs(): void;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38783. * being tilted forward or back and left or right.
  38784. */
  38785. export class DeviceOrientationCamera extends FreeCamera {
  38786. private _initialQuaternion;
  38787. private _quaternionCache;
  38788. private _tmpDragQuaternion;
  38789. private _disablePointerInputWhenUsingDeviceOrientation;
  38790. /**
  38791. * Creates a new device orientation camera
  38792. * @param name The name of the camera
  38793. * @param position The start position camera
  38794. * @param scene The scene the camera belongs to
  38795. */
  38796. constructor(name: string, position: Vector3, scene: Scene);
  38797. /**
  38798. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38799. */
  38800. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38801. private _dragFactor;
  38802. /**
  38803. * Enabled turning on the y axis when the orientation sensor is active
  38804. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38805. */
  38806. enableHorizontalDragging(dragFactor?: number): void;
  38807. /**
  38808. * Gets the current instance class name ("DeviceOrientationCamera").
  38809. * This helps avoiding instanceof at run time.
  38810. * @returns the class name
  38811. */
  38812. getClassName(): string;
  38813. /**
  38814. * @hidden
  38815. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38816. */
  38817. _checkInputs(): void;
  38818. /**
  38819. * Reset the camera to its default orientation on the specified axis only.
  38820. * @param axis The axis to reset
  38821. */
  38822. resetToCurrentRotation(axis?: Axis): void;
  38823. }
  38824. }
  38825. declare module BABYLON {
  38826. /**
  38827. * Defines supported buttons for XBox360 compatible gamepads
  38828. */
  38829. export enum Xbox360Button {
  38830. /** A */
  38831. A = 0,
  38832. /** B */
  38833. B = 1,
  38834. /** X */
  38835. X = 2,
  38836. /** Y */
  38837. Y = 3,
  38838. /** Start */
  38839. Start = 4,
  38840. /** Back */
  38841. Back = 5,
  38842. /** Left button */
  38843. LB = 6,
  38844. /** Right button */
  38845. RB = 7,
  38846. /** Left stick */
  38847. LeftStick = 8,
  38848. /** Right stick */
  38849. RightStick = 9
  38850. }
  38851. /** Defines values for XBox360 DPad */
  38852. export enum Xbox360Dpad {
  38853. /** Up */
  38854. Up = 0,
  38855. /** Down */
  38856. Down = 1,
  38857. /** Left */
  38858. Left = 2,
  38859. /** Right */
  38860. Right = 3
  38861. }
  38862. /**
  38863. * Defines a XBox360 gamepad
  38864. */
  38865. export class Xbox360Pad extends Gamepad {
  38866. private _leftTrigger;
  38867. private _rightTrigger;
  38868. private _onlefttriggerchanged;
  38869. private _onrighttriggerchanged;
  38870. private _onbuttondown;
  38871. private _onbuttonup;
  38872. private _ondpaddown;
  38873. private _ondpadup;
  38874. /** Observable raised when a button is pressed */
  38875. onButtonDownObservable: Observable<Xbox360Button>;
  38876. /** Observable raised when a button is released */
  38877. onButtonUpObservable: Observable<Xbox360Button>;
  38878. /** Observable raised when a pad is pressed */
  38879. onPadDownObservable: Observable<Xbox360Dpad>;
  38880. /** Observable raised when a pad is released */
  38881. onPadUpObservable: Observable<Xbox360Dpad>;
  38882. private _buttonA;
  38883. private _buttonB;
  38884. private _buttonX;
  38885. private _buttonY;
  38886. private _buttonBack;
  38887. private _buttonStart;
  38888. private _buttonLB;
  38889. private _buttonRB;
  38890. private _buttonLeftStick;
  38891. private _buttonRightStick;
  38892. private _dPadUp;
  38893. private _dPadDown;
  38894. private _dPadLeft;
  38895. private _dPadRight;
  38896. private _isXboxOnePad;
  38897. /**
  38898. * Creates a new XBox360 gamepad object
  38899. * @param id defines the id of this gamepad
  38900. * @param index defines its index
  38901. * @param gamepad defines the internal HTML gamepad object
  38902. * @param xboxOne defines if it is a XBox One gamepad
  38903. */
  38904. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38905. /**
  38906. * Defines the callback to call when left trigger is pressed
  38907. * @param callback defines the callback to use
  38908. */
  38909. onlefttriggerchanged(callback: (value: number) => void): void;
  38910. /**
  38911. * Defines the callback to call when right trigger is pressed
  38912. * @param callback defines the callback to use
  38913. */
  38914. onrighttriggerchanged(callback: (value: number) => void): void;
  38915. /**
  38916. * Gets the left trigger value
  38917. */
  38918. /**
  38919. * Sets the left trigger value
  38920. */
  38921. leftTrigger: number;
  38922. /**
  38923. * Gets the right trigger value
  38924. */
  38925. /**
  38926. * Sets the right trigger value
  38927. */
  38928. rightTrigger: number;
  38929. /**
  38930. * Defines the callback to call when a button is pressed
  38931. * @param callback defines the callback to use
  38932. */
  38933. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38934. /**
  38935. * Defines the callback to call when a button is released
  38936. * @param callback defines the callback to use
  38937. */
  38938. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38939. /**
  38940. * Defines the callback to call when a pad is pressed
  38941. * @param callback defines the callback to use
  38942. */
  38943. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38944. /**
  38945. * Defines the callback to call when a pad is released
  38946. * @param callback defines the callback to use
  38947. */
  38948. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38949. private _setButtonValue;
  38950. private _setDPadValue;
  38951. /**
  38952. * Gets the value of the `A` button
  38953. */
  38954. /**
  38955. * Sets the value of the `A` button
  38956. */
  38957. buttonA: number;
  38958. /**
  38959. * Gets the value of the `B` button
  38960. */
  38961. /**
  38962. * Sets the value of the `B` button
  38963. */
  38964. buttonB: number;
  38965. /**
  38966. * Gets the value of the `X` button
  38967. */
  38968. /**
  38969. * Sets the value of the `X` button
  38970. */
  38971. buttonX: number;
  38972. /**
  38973. * Gets the value of the `Y` button
  38974. */
  38975. /**
  38976. * Sets the value of the `Y` button
  38977. */
  38978. buttonY: number;
  38979. /**
  38980. * Gets the value of the `Start` button
  38981. */
  38982. /**
  38983. * Sets the value of the `Start` button
  38984. */
  38985. buttonStart: number;
  38986. /**
  38987. * Gets the value of the `Back` button
  38988. */
  38989. /**
  38990. * Sets the value of the `Back` button
  38991. */
  38992. buttonBack: number;
  38993. /**
  38994. * Gets the value of the `Left` button
  38995. */
  38996. /**
  38997. * Sets the value of the `Left` button
  38998. */
  38999. buttonLB: number;
  39000. /**
  39001. * Gets the value of the `Right` button
  39002. */
  39003. /**
  39004. * Sets the value of the `Right` button
  39005. */
  39006. buttonRB: number;
  39007. /**
  39008. * Gets the value of the Left joystick
  39009. */
  39010. /**
  39011. * Sets the value of the Left joystick
  39012. */
  39013. buttonLeftStick: number;
  39014. /**
  39015. * Gets the value of the Right joystick
  39016. */
  39017. /**
  39018. * Sets the value of the Right joystick
  39019. */
  39020. buttonRightStick: number;
  39021. /**
  39022. * Gets the value of D-pad up
  39023. */
  39024. /**
  39025. * Sets the value of D-pad up
  39026. */
  39027. dPadUp: number;
  39028. /**
  39029. * Gets the value of D-pad down
  39030. */
  39031. /**
  39032. * Sets the value of D-pad down
  39033. */
  39034. dPadDown: number;
  39035. /**
  39036. * Gets the value of D-pad left
  39037. */
  39038. /**
  39039. * Sets the value of D-pad left
  39040. */
  39041. dPadLeft: number;
  39042. /**
  39043. * Gets the value of D-pad right
  39044. */
  39045. /**
  39046. * Sets the value of D-pad right
  39047. */
  39048. dPadRight: number;
  39049. /**
  39050. * Force the gamepad to synchronize with device values
  39051. */
  39052. update(): void;
  39053. /**
  39054. * Disposes the gamepad
  39055. */
  39056. dispose(): void;
  39057. }
  39058. }
  39059. declare module BABYLON {
  39060. /**
  39061. * Defines supported buttons for DualShock compatible gamepads
  39062. */
  39063. export enum DualShockButton {
  39064. /** Cross */
  39065. Cross = 0,
  39066. /** Circle */
  39067. Circle = 1,
  39068. /** Square */
  39069. Square = 2,
  39070. /** Triangle */
  39071. Triangle = 3,
  39072. /** Options */
  39073. Options = 4,
  39074. /** Share */
  39075. Share = 5,
  39076. /** L1 */
  39077. L1 = 6,
  39078. /** R1 */
  39079. R1 = 7,
  39080. /** Left stick */
  39081. LeftStick = 8,
  39082. /** Right stick */
  39083. RightStick = 9
  39084. }
  39085. /** Defines values for DualShock DPad */
  39086. export enum DualShockDpad {
  39087. /** Up */
  39088. Up = 0,
  39089. /** Down */
  39090. Down = 1,
  39091. /** Left */
  39092. Left = 2,
  39093. /** Right */
  39094. Right = 3
  39095. }
  39096. /**
  39097. * Defines a DualShock gamepad
  39098. */
  39099. export class DualShockPad extends Gamepad {
  39100. private _leftTrigger;
  39101. private _rightTrigger;
  39102. private _onlefttriggerchanged;
  39103. private _onrighttriggerchanged;
  39104. private _onbuttondown;
  39105. private _onbuttonup;
  39106. private _ondpaddown;
  39107. private _ondpadup;
  39108. /** Observable raised when a button is pressed */
  39109. onButtonDownObservable: Observable<DualShockButton>;
  39110. /** Observable raised when a button is released */
  39111. onButtonUpObservable: Observable<DualShockButton>;
  39112. /** Observable raised when a pad is pressed */
  39113. onPadDownObservable: Observable<DualShockDpad>;
  39114. /** Observable raised when a pad is released */
  39115. onPadUpObservable: Observable<DualShockDpad>;
  39116. private _buttonCross;
  39117. private _buttonCircle;
  39118. private _buttonSquare;
  39119. private _buttonTriangle;
  39120. private _buttonShare;
  39121. private _buttonOptions;
  39122. private _buttonL1;
  39123. private _buttonR1;
  39124. private _buttonLeftStick;
  39125. private _buttonRightStick;
  39126. private _dPadUp;
  39127. private _dPadDown;
  39128. private _dPadLeft;
  39129. private _dPadRight;
  39130. /**
  39131. * Creates a new DualShock gamepad object
  39132. * @param id defines the id of this gamepad
  39133. * @param index defines its index
  39134. * @param gamepad defines the internal HTML gamepad object
  39135. */
  39136. constructor(id: string, index: number, gamepad: any);
  39137. /**
  39138. * Defines the callback to call when left trigger is pressed
  39139. * @param callback defines the callback to use
  39140. */
  39141. onlefttriggerchanged(callback: (value: number) => void): void;
  39142. /**
  39143. * Defines the callback to call when right trigger is pressed
  39144. * @param callback defines the callback to use
  39145. */
  39146. onrighttriggerchanged(callback: (value: number) => void): void;
  39147. /**
  39148. * Gets the left trigger value
  39149. */
  39150. /**
  39151. * Sets the left trigger value
  39152. */
  39153. leftTrigger: number;
  39154. /**
  39155. * Gets the right trigger value
  39156. */
  39157. /**
  39158. * Sets the right trigger value
  39159. */
  39160. rightTrigger: number;
  39161. /**
  39162. * Defines the callback to call when a button is pressed
  39163. * @param callback defines the callback to use
  39164. */
  39165. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39166. /**
  39167. * Defines the callback to call when a button is released
  39168. * @param callback defines the callback to use
  39169. */
  39170. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39171. /**
  39172. * Defines the callback to call when a pad is pressed
  39173. * @param callback defines the callback to use
  39174. */
  39175. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39176. /**
  39177. * Defines the callback to call when a pad is released
  39178. * @param callback defines the callback to use
  39179. */
  39180. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39181. private _setButtonValue;
  39182. private _setDPadValue;
  39183. /**
  39184. * Gets the value of the `Cross` button
  39185. */
  39186. /**
  39187. * Sets the value of the `Cross` button
  39188. */
  39189. buttonCross: number;
  39190. /**
  39191. * Gets the value of the `Circle` button
  39192. */
  39193. /**
  39194. * Sets the value of the `Circle` button
  39195. */
  39196. buttonCircle: number;
  39197. /**
  39198. * Gets the value of the `Square` button
  39199. */
  39200. /**
  39201. * Sets the value of the `Square` button
  39202. */
  39203. buttonSquare: number;
  39204. /**
  39205. * Gets the value of the `Triangle` button
  39206. */
  39207. /**
  39208. * Sets the value of the `Triangle` button
  39209. */
  39210. buttonTriangle: number;
  39211. /**
  39212. * Gets the value of the `Options` button
  39213. */
  39214. /**
  39215. * Sets the value of the `Options` button
  39216. */
  39217. buttonOptions: number;
  39218. /**
  39219. * Gets the value of the `Share` button
  39220. */
  39221. /**
  39222. * Sets the value of the `Share` button
  39223. */
  39224. buttonShare: number;
  39225. /**
  39226. * Gets the value of the `L1` button
  39227. */
  39228. /**
  39229. * Sets the value of the `L1` button
  39230. */
  39231. buttonL1: number;
  39232. /**
  39233. * Gets the value of the `R1` button
  39234. */
  39235. /**
  39236. * Sets the value of the `R1` button
  39237. */
  39238. buttonR1: number;
  39239. /**
  39240. * Gets the value of the Left joystick
  39241. */
  39242. /**
  39243. * Sets the value of the Left joystick
  39244. */
  39245. buttonLeftStick: number;
  39246. /**
  39247. * Gets the value of the Right joystick
  39248. */
  39249. /**
  39250. * Sets the value of the Right joystick
  39251. */
  39252. buttonRightStick: number;
  39253. /**
  39254. * Gets the value of D-pad up
  39255. */
  39256. /**
  39257. * Sets the value of D-pad up
  39258. */
  39259. dPadUp: number;
  39260. /**
  39261. * Gets the value of D-pad down
  39262. */
  39263. /**
  39264. * Sets the value of D-pad down
  39265. */
  39266. dPadDown: number;
  39267. /**
  39268. * Gets the value of D-pad left
  39269. */
  39270. /**
  39271. * Sets the value of D-pad left
  39272. */
  39273. dPadLeft: number;
  39274. /**
  39275. * Gets the value of D-pad right
  39276. */
  39277. /**
  39278. * Sets the value of D-pad right
  39279. */
  39280. dPadRight: number;
  39281. /**
  39282. * Force the gamepad to synchronize with device values
  39283. */
  39284. update(): void;
  39285. /**
  39286. * Disposes the gamepad
  39287. */
  39288. dispose(): void;
  39289. }
  39290. }
  39291. declare module BABYLON {
  39292. /**
  39293. * Manager for handling gamepads
  39294. */
  39295. export class GamepadManager {
  39296. private _scene?;
  39297. private _babylonGamepads;
  39298. private _oneGamepadConnected;
  39299. /** @hidden */
  39300. _isMonitoring: boolean;
  39301. private _gamepadEventSupported;
  39302. private _gamepadSupport;
  39303. /**
  39304. * observable to be triggered when the gamepad controller has been connected
  39305. */
  39306. onGamepadConnectedObservable: Observable<Gamepad>;
  39307. /**
  39308. * observable to be triggered when the gamepad controller has been disconnected
  39309. */
  39310. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39311. private _onGamepadConnectedEvent;
  39312. private _onGamepadDisconnectedEvent;
  39313. /**
  39314. * Initializes the gamepad manager
  39315. * @param _scene BabylonJS scene
  39316. */
  39317. constructor(_scene?: Scene | undefined);
  39318. /**
  39319. * The gamepads in the game pad manager
  39320. */
  39321. readonly gamepads: Gamepad[];
  39322. /**
  39323. * Get the gamepad controllers based on type
  39324. * @param type The type of gamepad controller
  39325. * @returns Nullable gamepad
  39326. */
  39327. getGamepadByType(type?: number): Nullable<Gamepad>;
  39328. /**
  39329. * Disposes the gamepad manager
  39330. */
  39331. dispose(): void;
  39332. private _addNewGamepad;
  39333. private _startMonitoringGamepads;
  39334. private _stopMonitoringGamepads;
  39335. /** @hidden */
  39336. _checkGamepadsStatus(): void;
  39337. private _updateGamepadObjects;
  39338. }
  39339. }
  39340. declare module BABYLON {
  39341. interface Scene {
  39342. /** @hidden */
  39343. _gamepadManager: Nullable<GamepadManager>;
  39344. /**
  39345. * Gets the gamepad manager associated with the scene
  39346. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39347. */
  39348. gamepadManager: GamepadManager;
  39349. }
  39350. /**
  39351. * Interface representing a free camera inputs manager
  39352. */
  39353. interface FreeCameraInputsManager {
  39354. /**
  39355. * Adds gamepad input support to the FreeCameraInputsManager.
  39356. * @returns the FreeCameraInputsManager
  39357. */
  39358. addGamepad(): FreeCameraInputsManager;
  39359. }
  39360. /**
  39361. * Interface representing an arc rotate camera inputs manager
  39362. */
  39363. interface ArcRotateCameraInputsManager {
  39364. /**
  39365. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39366. * @returns the camera inputs manager
  39367. */
  39368. addGamepad(): ArcRotateCameraInputsManager;
  39369. }
  39370. /**
  39371. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39372. */
  39373. export class GamepadSystemSceneComponent implements ISceneComponent {
  39374. /**
  39375. * The component name helpfull to identify the component in the list of scene components.
  39376. */
  39377. readonly name: string;
  39378. /**
  39379. * The scene the component belongs to.
  39380. */
  39381. scene: Scene;
  39382. /**
  39383. * Creates a new instance of the component for the given scene
  39384. * @param scene Defines the scene to register the component in
  39385. */
  39386. constructor(scene: Scene);
  39387. /**
  39388. * Registers the component in a given scene
  39389. */
  39390. register(): void;
  39391. /**
  39392. * Rebuilds the elements related to this component in case of
  39393. * context lost for instance.
  39394. */
  39395. rebuild(): void;
  39396. /**
  39397. * Disposes the component and the associated ressources
  39398. */
  39399. dispose(): void;
  39400. private _beforeCameraUpdate;
  39401. }
  39402. }
  39403. declare module BABYLON {
  39404. /**
  39405. * 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,
  39406. * which still works and will still be found in many Playgrounds.
  39407. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39408. */
  39409. export class UniversalCamera extends TouchCamera {
  39410. /**
  39411. * Defines the gamepad rotation sensiblity.
  39412. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39413. */
  39414. gamepadAngularSensibility: number;
  39415. /**
  39416. * Defines the gamepad move sensiblity.
  39417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39418. */
  39419. gamepadMoveSensibility: number;
  39420. /**
  39421. * 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,
  39422. * which still works and will still be found in many Playgrounds.
  39423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39424. * @param name Define the name of the camera in the scene
  39425. * @param position Define the start position of the camera in the scene
  39426. * @param scene Define the scene the camera belongs to
  39427. */
  39428. constructor(name: string, position: Vector3, scene: Scene);
  39429. /**
  39430. * Gets the current object class name.
  39431. * @return the class name
  39432. */
  39433. getClassName(): string;
  39434. }
  39435. }
  39436. declare module BABYLON {
  39437. /**
  39438. * This represents a FPS type of camera. This is only here for back compat purpose.
  39439. * Please use the UniversalCamera instead as both are identical.
  39440. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39441. */
  39442. export class GamepadCamera extends UniversalCamera {
  39443. /**
  39444. * Instantiates a new Gamepad Camera
  39445. * This represents a FPS type of camera. This is only here for back compat purpose.
  39446. * Please use the UniversalCamera instead as both are identical.
  39447. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39448. * @param name Define the name of the camera in the scene
  39449. * @param position Define the start position of the camera in the scene
  39450. * @param scene Define the scene the camera belongs to
  39451. */
  39452. constructor(name: string, position: Vector3, scene: Scene);
  39453. /**
  39454. * Gets the current object class name.
  39455. * @return the class name
  39456. */
  39457. getClassName(): string;
  39458. }
  39459. }
  39460. declare module BABYLON {
  39461. /** @hidden */
  39462. export var passPixelShader: {
  39463. name: string;
  39464. shader: string;
  39465. };
  39466. }
  39467. declare module BABYLON {
  39468. /** @hidden */
  39469. export var passCubePixelShader: {
  39470. name: string;
  39471. shader: string;
  39472. };
  39473. }
  39474. declare module BABYLON {
  39475. /**
  39476. * PassPostProcess which produces an output the same as it's input
  39477. */
  39478. export class PassPostProcess extends PostProcess {
  39479. /**
  39480. * Creates the PassPostProcess
  39481. * @param name The name of the effect.
  39482. * @param options The required width/height ratio to downsize to before computing the render pass.
  39483. * @param camera The camera to apply the render pass to.
  39484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39485. * @param engine The engine which the post process will be applied. (default: current engine)
  39486. * @param reusable If the post process can be reused on the same frame. (default: false)
  39487. * @param textureType The type of texture to be used when performing the post processing.
  39488. * @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)
  39489. */
  39490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39491. }
  39492. /**
  39493. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39494. */
  39495. export class PassCubePostProcess extends PostProcess {
  39496. private _face;
  39497. /**
  39498. * Gets or sets the cube face to display.
  39499. * * 0 is +X
  39500. * * 1 is -X
  39501. * * 2 is +Y
  39502. * * 3 is -Y
  39503. * * 4 is +Z
  39504. * * 5 is -Z
  39505. */
  39506. face: number;
  39507. /**
  39508. * Creates the PassCubePostProcess
  39509. * @param name The name of the effect.
  39510. * @param options The required width/height ratio to downsize to before computing the render pass.
  39511. * @param camera The camera to apply the render pass to.
  39512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39513. * @param engine The engine which the post process will be applied. (default: current engine)
  39514. * @param reusable If the post process can be reused on the same frame. (default: false)
  39515. * @param textureType The type of texture to be used when performing the post processing.
  39516. * @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)
  39517. */
  39518. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39519. }
  39520. }
  39521. declare module BABYLON {
  39522. /** @hidden */
  39523. export var anaglyphPixelShader: {
  39524. name: string;
  39525. shader: string;
  39526. };
  39527. }
  39528. declare module BABYLON {
  39529. /**
  39530. * Postprocess used to generate anaglyphic rendering
  39531. */
  39532. export class AnaglyphPostProcess extends PostProcess {
  39533. private _passedProcess;
  39534. /**
  39535. * Creates a new AnaglyphPostProcess
  39536. * @param name defines postprocess name
  39537. * @param options defines creation options or target ratio scale
  39538. * @param rigCameras defines cameras using this postprocess
  39539. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39540. * @param engine defines hosting engine
  39541. * @param reusable defines if the postprocess will be reused multiple times per frame
  39542. */
  39543. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39544. }
  39545. }
  39546. declare module BABYLON {
  39547. /**
  39548. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39549. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39550. */
  39551. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39552. /**
  39553. * Creates a new AnaglyphArcRotateCamera
  39554. * @param name defines camera name
  39555. * @param alpha defines alpha angle (in radians)
  39556. * @param beta defines beta angle (in radians)
  39557. * @param radius defines radius
  39558. * @param target defines camera target
  39559. * @param interaxialDistance defines distance between each color axis
  39560. * @param scene defines the hosting scene
  39561. */
  39562. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39563. /**
  39564. * Gets camera class name
  39565. * @returns AnaglyphArcRotateCamera
  39566. */
  39567. getClassName(): string;
  39568. }
  39569. }
  39570. declare module BABYLON {
  39571. /**
  39572. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39573. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39574. */
  39575. export class AnaglyphFreeCamera extends FreeCamera {
  39576. /**
  39577. * Creates a new AnaglyphFreeCamera
  39578. * @param name defines camera name
  39579. * @param position defines initial position
  39580. * @param interaxialDistance defines distance between each color axis
  39581. * @param scene defines the hosting scene
  39582. */
  39583. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39584. /**
  39585. * Gets camera class name
  39586. * @returns AnaglyphFreeCamera
  39587. */
  39588. getClassName(): string;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39594. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39595. */
  39596. export class AnaglyphGamepadCamera extends GamepadCamera {
  39597. /**
  39598. * Creates a new AnaglyphGamepadCamera
  39599. * @param name defines camera name
  39600. * @param position defines initial position
  39601. * @param interaxialDistance defines distance between each color axis
  39602. * @param scene defines the hosting scene
  39603. */
  39604. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39605. /**
  39606. * Gets camera class name
  39607. * @returns AnaglyphGamepadCamera
  39608. */
  39609. getClassName(): string;
  39610. }
  39611. }
  39612. declare module BABYLON {
  39613. /**
  39614. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39615. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39616. */
  39617. export class AnaglyphUniversalCamera extends UniversalCamera {
  39618. /**
  39619. * Creates a new AnaglyphUniversalCamera
  39620. * @param name defines camera name
  39621. * @param position defines initial position
  39622. * @param interaxialDistance defines distance between each color axis
  39623. * @param scene defines the hosting scene
  39624. */
  39625. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39626. /**
  39627. * Gets camera class name
  39628. * @returns AnaglyphUniversalCamera
  39629. */
  39630. getClassName(): string;
  39631. }
  39632. }
  39633. declare module BABYLON {
  39634. /** @hidden */
  39635. export var stereoscopicInterlacePixelShader: {
  39636. name: string;
  39637. shader: string;
  39638. };
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39643. */
  39644. export class StereoscopicInterlacePostProcess extends PostProcess {
  39645. private _stepSize;
  39646. private _passedProcess;
  39647. /**
  39648. * Initializes a StereoscopicInterlacePostProcess
  39649. * @param name The name of the effect.
  39650. * @param rigCameras The rig cameras to be appled to the post process
  39651. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39653. * @param engine The engine which the post process will be applied. (default: current engine)
  39654. * @param reusable If the post process can be reused on the same frame. (default: false)
  39655. */
  39656. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39657. }
  39658. }
  39659. declare module BABYLON {
  39660. /**
  39661. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39662. * @see http://doc.babylonjs.com/features/cameras
  39663. */
  39664. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39665. /**
  39666. * Creates a new StereoscopicArcRotateCamera
  39667. * @param name defines camera name
  39668. * @param alpha defines alpha angle (in radians)
  39669. * @param beta defines beta angle (in radians)
  39670. * @param radius defines radius
  39671. * @param target defines camera target
  39672. * @param interaxialDistance defines distance between each color axis
  39673. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39674. * @param scene defines the hosting scene
  39675. */
  39676. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39677. /**
  39678. * Gets camera class name
  39679. * @returns StereoscopicArcRotateCamera
  39680. */
  39681. getClassName(): string;
  39682. }
  39683. }
  39684. declare module BABYLON {
  39685. /**
  39686. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39687. * @see http://doc.babylonjs.com/features/cameras
  39688. */
  39689. export class StereoscopicFreeCamera extends FreeCamera {
  39690. /**
  39691. * Creates a new StereoscopicFreeCamera
  39692. * @param name defines camera name
  39693. * @param position defines initial position
  39694. * @param interaxialDistance defines distance between each color axis
  39695. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39696. * @param scene defines the hosting scene
  39697. */
  39698. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39699. /**
  39700. * Gets camera class name
  39701. * @returns StereoscopicFreeCamera
  39702. */
  39703. getClassName(): string;
  39704. }
  39705. }
  39706. declare module BABYLON {
  39707. /**
  39708. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39709. * @see http://doc.babylonjs.com/features/cameras
  39710. */
  39711. export class StereoscopicGamepadCamera extends GamepadCamera {
  39712. /**
  39713. * Creates a new StereoscopicGamepadCamera
  39714. * @param name defines camera name
  39715. * @param position defines initial position
  39716. * @param interaxialDistance defines distance between each color axis
  39717. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39718. * @param scene defines the hosting scene
  39719. */
  39720. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39721. /**
  39722. * Gets camera class name
  39723. * @returns StereoscopicGamepadCamera
  39724. */
  39725. getClassName(): string;
  39726. }
  39727. }
  39728. declare module BABYLON {
  39729. /**
  39730. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39731. * @see http://doc.babylonjs.com/features/cameras
  39732. */
  39733. export class StereoscopicUniversalCamera extends UniversalCamera {
  39734. /**
  39735. * Creates a new StereoscopicUniversalCamera
  39736. * @param name defines camera name
  39737. * @param position defines initial position
  39738. * @param interaxialDistance defines distance between each color axis
  39739. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39740. * @param scene defines the hosting scene
  39741. */
  39742. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39743. /**
  39744. * Gets camera class name
  39745. * @returns StereoscopicUniversalCamera
  39746. */
  39747. getClassName(): string;
  39748. }
  39749. }
  39750. declare module BABYLON {
  39751. /**
  39752. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39753. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39754. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39755. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39756. */
  39757. export class VirtualJoysticksCamera extends FreeCamera {
  39758. /**
  39759. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39760. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39761. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39762. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39763. * @param name Define the name of the camera in the scene
  39764. * @param position Define the start position of the camera in the scene
  39765. * @param scene Define the scene the camera belongs to
  39766. */
  39767. constructor(name: string, position: Vector3, scene: Scene);
  39768. /**
  39769. * Gets the current object class name.
  39770. * @return the class name
  39771. */
  39772. getClassName(): string;
  39773. }
  39774. }
  39775. declare module BABYLON {
  39776. /**
  39777. * This represents all the required metrics to create a VR camera.
  39778. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39779. */
  39780. export class VRCameraMetrics {
  39781. /**
  39782. * Define the horizontal resolution off the screen.
  39783. */
  39784. hResolution: number;
  39785. /**
  39786. * Define the vertical resolution off the screen.
  39787. */
  39788. vResolution: number;
  39789. /**
  39790. * Define the horizontal screen size.
  39791. */
  39792. hScreenSize: number;
  39793. /**
  39794. * Define the vertical screen size.
  39795. */
  39796. vScreenSize: number;
  39797. /**
  39798. * Define the vertical screen center position.
  39799. */
  39800. vScreenCenter: number;
  39801. /**
  39802. * Define the distance of the eyes to the screen.
  39803. */
  39804. eyeToScreenDistance: number;
  39805. /**
  39806. * Define the distance between both lenses
  39807. */
  39808. lensSeparationDistance: number;
  39809. /**
  39810. * Define the distance between both viewer's eyes.
  39811. */
  39812. interpupillaryDistance: number;
  39813. /**
  39814. * Define the distortion factor of the VR postprocess.
  39815. * Please, touch with care.
  39816. */
  39817. distortionK: number[];
  39818. /**
  39819. * Define the chromatic aberration correction factors for the VR post process.
  39820. */
  39821. chromaAbCorrection: number[];
  39822. /**
  39823. * Define the scale factor of the post process.
  39824. * The smaller the better but the slower.
  39825. */
  39826. postProcessScaleFactor: number;
  39827. /**
  39828. * Define an offset for the lens center.
  39829. */
  39830. lensCenterOffset: number;
  39831. /**
  39832. * Define if the current vr camera should compensate the distortion of the lense or not.
  39833. */
  39834. compensateDistortion: boolean;
  39835. /**
  39836. * Defines if multiview should be enabled when rendering (Default: false)
  39837. */
  39838. multiviewEnabled: boolean;
  39839. /**
  39840. * Gets the rendering aspect ratio based on the provided resolutions.
  39841. */
  39842. readonly aspectRatio: number;
  39843. /**
  39844. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39845. */
  39846. readonly aspectRatioFov: number;
  39847. /**
  39848. * @hidden
  39849. */
  39850. readonly leftHMatrix: Matrix;
  39851. /**
  39852. * @hidden
  39853. */
  39854. readonly rightHMatrix: Matrix;
  39855. /**
  39856. * @hidden
  39857. */
  39858. readonly leftPreViewMatrix: Matrix;
  39859. /**
  39860. * @hidden
  39861. */
  39862. readonly rightPreViewMatrix: Matrix;
  39863. /**
  39864. * Get the default VRMetrics based on the most generic setup.
  39865. * @returns the default vr metrics
  39866. */
  39867. static GetDefault(): VRCameraMetrics;
  39868. }
  39869. }
  39870. declare module BABYLON {
  39871. /** @hidden */
  39872. export var vrDistortionCorrectionPixelShader: {
  39873. name: string;
  39874. shader: string;
  39875. };
  39876. }
  39877. declare module BABYLON {
  39878. /**
  39879. * VRDistortionCorrectionPostProcess used for mobile VR
  39880. */
  39881. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39882. private _isRightEye;
  39883. private _distortionFactors;
  39884. private _postProcessScaleFactor;
  39885. private _lensCenterOffset;
  39886. private _scaleIn;
  39887. private _scaleFactor;
  39888. private _lensCenter;
  39889. /**
  39890. * Initializes the VRDistortionCorrectionPostProcess
  39891. * @param name The name of the effect.
  39892. * @param camera The camera to apply the render pass to.
  39893. * @param isRightEye If this is for the right eye distortion
  39894. * @param vrMetrics All the required metrics for the VR camera
  39895. */
  39896. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39897. }
  39898. }
  39899. declare module BABYLON {
  39900. /**
  39901. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39902. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39903. */
  39904. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39905. /**
  39906. * Creates a new VRDeviceOrientationArcRotateCamera
  39907. * @param name defines camera name
  39908. * @param alpha defines the camera rotation along the logitudinal axis
  39909. * @param beta defines the camera rotation along the latitudinal axis
  39910. * @param radius defines the camera distance from its target
  39911. * @param target defines the camera target
  39912. * @param scene defines the scene the camera belongs to
  39913. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39914. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39915. */
  39916. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39917. /**
  39918. * Gets camera class name
  39919. * @returns VRDeviceOrientationArcRotateCamera
  39920. */
  39921. getClassName(): string;
  39922. }
  39923. }
  39924. declare module BABYLON {
  39925. /**
  39926. * Camera used to simulate VR rendering (based on FreeCamera)
  39927. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39928. */
  39929. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39930. /**
  39931. * Creates a new VRDeviceOrientationFreeCamera
  39932. * @param name defines camera name
  39933. * @param position defines the start position of the camera
  39934. * @param scene defines the scene the camera belongs to
  39935. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39936. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39937. */
  39938. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39939. /**
  39940. * Gets camera class name
  39941. * @returns VRDeviceOrientationFreeCamera
  39942. */
  39943. getClassName(): string;
  39944. }
  39945. }
  39946. declare module BABYLON {
  39947. /**
  39948. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39949. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39950. */
  39951. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39952. /**
  39953. * Creates a new VRDeviceOrientationGamepadCamera
  39954. * @param name defines camera name
  39955. * @param position defines the start position of the camera
  39956. * @param scene defines the scene the camera belongs to
  39957. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39958. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39959. */
  39960. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39961. /**
  39962. * Gets camera class name
  39963. * @returns VRDeviceOrientationGamepadCamera
  39964. */
  39965. getClassName(): string;
  39966. }
  39967. }
  39968. declare module BABYLON {
  39969. /**
  39970. * Base class of materials working in push mode in babylon JS
  39971. * @hidden
  39972. */
  39973. export class PushMaterial extends Material {
  39974. protected _activeEffect: Effect;
  39975. protected _normalMatrix: Matrix;
  39976. /**
  39977. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39978. * This means that the material can keep using a previous shader while a new one is being compiled.
  39979. * This is mostly used when shader parallel compilation is supported (true by default)
  39980. */
  39981. allowShaderHotSwapping: boolean;
  39982. constructor(name: string, scene: Scene);
  39983. getEffect(): Effect;
  39984. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39985. /**
  39986. * Binds the given world matrix to the active effect
  39987. *
  39988. * @param world the matrix to bind
  39989. */
  39990. bindOnlyWorldMatrix(world: Matrix): void;
  39991. /**
  39992. * Binds the given normal matrix to the active effect
  39993. *
  39994. * @param normalMatrix the matrix to bind
  39995. */
  39996. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39997. bind(world: Matrix, mesh?: Mesh): void;
  39998. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39999. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40000. }
  40001. }
  40002. declare module BABYLON {
  40003. /**
  40004. * This groups all the flags used to control the materials channel.
  40005. */
  40006. export class MaterialFlags {
  40007. private static _DiffuseTextureEnabled;
  40008. /**
  40009. * Are diffuse textures enabled in the application.
  40010. */
  40011. static DiffuseTextureEnabled: boolean;
  40012. private static _AmbientTextureEnabled;
  40013. /**
  40014. * Are ambient textures enabled in the application.
  40015. */
  40016. static AmbientTextureEnabled: boolean;
  40017. private static _OpacityTextureEnabled;
  40018. /**
  40019. * Are opacity textures enabled in the application.
  40020. */
  40021. static OpacityTextureEnabled: boolean;
  40022. private static _ReflectionTextureEnabled;
  40023. /**
  40024. * Are reflection textures enabled in the application.
  40025. */
  40026. static ReflectionTextureEnabled: boolean;
  40027. private static _EmissiveTextureEnabled;
  40028. /**
  40029. * Are emissive textures enabled in the application.
  40030. */
  40031. static EmissiveTextureEnabled: boolean;
  40032. private static _SpecularTextureEnabled;
  40033. /**
  40034. * Are specular textures enabled in the application.
  40035. */
  40036. static SpecularTextureEnabled: boolean;
  40037. private static _BumpTextureEnabled;
  40038. /**
  40039. * Are bump textures enabled in the application.
  40040. */
  40041. static BumpTextureEnabled: boolean;
  40042. private static _LightmapTextureEnabled;
  40043. /**
  40044. * Are lightmap textures enabled in the application.
  40045. */
  40046. static LightmapTextureEnabled: boolean;
  40047. private static _RefractionTextureEnabled;
  40048. /**
  40049. * Are refraction textures enabled in the application.
  40050. */
  40051. static RefractionTextureEnabled: boolean;
  40052. private static _ColorGradingTextureEnabled;
  40053. /**
  40054. * Are color grading textures enabled in the application.
  40055. */
  40056. static ColorGradingTextureEnabled: boolean;
  40057. private static _FresnelEnabled;
  40058. /**
  40059. * Are fresnels enabled in the application.
  40060. */
  40061. static FresnelEnabled: boolean;
  40062. private static _ClearCoatTextureEnabled;
  40063. /**
  40064. * Are clear coat textures enabled in the application.
  40065. */
  40066. static ClearCoatTextureEnabled: boolean;
  40067. private static _ClearCoatBumpTextureEnabled;
  40068. /**
  40069. * Are clear coat bump textures enabled in the application.
  40070. */
  40071. static ClearCoatBumpTextureEnabled: boolean;
  40072. private static _ClearCoatTintTextureEnabled;
  40073. /**
  40074. * Are clear coat tint textures enabled in the application.
  40075. */
  40076. static ClearCoatTintTextureEnabled: boolean;
  40077. private static _SheenTextureEnabled;
  40078. /**
  40079. * Are sheen textures enabled in the application.
  40080. */
  40081. static SheenTextureEnabled: boolean;
  40082. private static _AnisotropicTextureEnabled;
  40083. /**
  40084. * Are anisotropic textures enabled in the application.
  40085. */
  40086. static AnisotropicTextureEnabled: boolean;
  40087. private static _ThicknessTextureEnabled;
  40088. /**
  40089. * Are thickness textures enabled in the application.
  40090. */
  40091. static ThicknessTextureEnabled: boolean;
  40092. }
  40093. }
  40094. declare module BABYLON {
  40095. /** @hidden */
  40096. export var defaultFragmentDeclaration: {
  40097. name: string;
  40098. shader: string;
  40099. };
  40100. }
  40101. declare module BABYLON {
  40102. /** @hidden */
  40103. export var defaultUboDeclaration: {
  40104. name: string;
  40105. shader: string;
  40106. };
  40107. }
  40108. declare module BABYLON {
  40109. /** @hidden */
  40110. export var lightFragmentDeclaration: {
  40111. name: string;
  40112. shader: string;
  40113. };
  40114. }
  40115. declare module BABYLON {
  40116. /** @hidden */
  40117. export var lightUboDeclaration: {
  40118. name: string;
  40119. shader: string;
  40120. };
  40121. }
  40122. declare module BABYLON {
  40123. /** @hidden */
  40124. export var lightsFragmentFunctions: {
  40125. name: string;
  40126. shader: string;
  40127. };
  40128. }
  40129. declare module BABYLON {
  40130. /** @hidden */
  40131. export var shadowsFragmentFunctions: {
  40132. name: string;
  40133. shader: string;
  40134. };
  40135. }
  40136. declare module BABYLON {
  40137. /** @hidden */
  40138. export var fresnelFunction: {
  40139. name: string;
  40140. shader: string;
  40141. };
  40142. }
  40143. declare module BABYLON {
  40144. /** @hidden */
  40145. export var reflectionFunction: {
  40146. name: string;
  40147. shader: string;
  40148. };
  40149. }
  40150. declare module BABYLON {
  40151. /** @hidden */
  40152. export var bumpFragmentFunctions: {
  40153. name: string;
  40154. shader: string;
  40155. };
  40156. }
  40157. declare module BABYLON {
  40158. /** @hidden */
  40159. export var logDepthDeclaration: {
  40160. name: string;
  40161. shader: string;
  40162. };
  40163. }
  40164. declare module BABYLON {
  40165. /** @hidden */
  40166. export var bumpFragment: {
  40167. name: string;
  40168. shader: string;
  40169. };
  40170. }
  40171. declare module BABYLON {
  40172. /** @hidden */
  40173. export var depthPrePass: {
  40174. name: string;
  40175. shader: string;
  40176. };
  40177. }
  40178. declare module BABYLON {
  40179. /** @hidden */
  40180. export var lightFragment: {
  40181. name: string;
  40182. shader: string;
  40183. };
  40184. }
  40185. declare module BABYLON {
  40186. /** @hidden */
  40187. export var logDepthFragment: {
  40188. name: string;
  40189. shader: string;
  40190. };
  40191. }
  40192. declare module BABYLON {
  40193. /** @hidden */
  40194. export var defaultPixelShader: {
  40195. name: string;
  40196. shader: string;
  40197. };
  40198. }
  40199. declare module BABYLON {
  40200. /** @hidden */
  40201. export var defaultVertexDeclaration: {
  40202. name: string;
  40203. shader: string;
  40204. };
  40205. }
  40206. declare module BABYLON {
  40207. /** @hidden */
  40208. export var bumpVertexDeclaration: {
  40209. name: string;
  40210. shader: string;
  40211. };
  40212. }
  40213. declare module BABYLON {
  40214. /** @hidden */
  40215. export var bumpVertex: {
  40216. name: string;
  40217. shader: string;
  40218. };
  40219. }
  40220. declare module BABYLON {
  40221. /** @hidden */
  40222. export var fogVertex: {
  40223. name: string;
  40224. shader: string;
  40225. };
  40226. }
  40227. declare module BABYLON {
  40228. /** @hidden */
  40229. export var shadowsVertex: {
  40230. name: string;
  40231. shader: string;
  40232. };
  40233. }
  40234. declare module BABYLON {
  40235. /** @hidden */
  40236. export var pointCloudVertex: {
  40237. name: string;
  40238. shader: string;
  40239. };
  40240. }
  40241. declare module BABYLON {
  40242. /** @hidden */
  40243. export var logDepthVertex: {
  40244. name: string;
  40245. shader: string;
  40246. };
  40247. }
  40248. declare module BABYLON {
  40249. /** @hidden */
  40250. export var defaultVertexShader: {
  40251. name: string;
  40252. shader: string;
  40253. };
  40254. }
  40255. declare module BABYLON {
  40256. /** @hidden */
  40257. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40258. MAINUV1: boolean;
  40259. MAINUV2: boolean;
  40260. DIFFUSE: boolean;
  40261. DIFFUSEDIRECTUV: number;
  40262. AMBIENT: boolean;
  40263. AMBIENTDIRECTUV: number;
  40264. OPACITY: boolean;
  40265. OPACITYDIRECTUV: number;
  40266. OPACITYRGB: boolean;
  40267. REFLECTION: boolean;
  40268. EMISSIVE: boolean;
  40269. EMISSIVEDIRECTUV: number;
  40270. SPECULAR: boolean;
  40271. SPECULARDIRECTUV: number;
  40272. BUMP: boolean;
  40273. BUMPDIRECTUV: number;
  40274. PARALLAX: boolean;
  40275. PARALLAXOCCLUSION: boolean;
  40276. SPECULAROVERALPHA: boolean;
  40277. CLIPPLANE: boolean;
  40278. CLIPPLANE2: boolean;
  40279. CLIPPLANE3: boolean;
  40280. CLIPPLANE4: boolean;
  40281. ALPHATEST: boolean;
  40282. DEPTHPREPASS: boolean;
  40283. ALPHAFROMDIFFUSE: boolean;
  40284. POINTSIZE: boolean;
  40285. FOG: boolean;
  40286. SPECULARTERM: boolean;
  40287. DIFFUSEFRESNEL: boolean;
  40288. OPACITYFRESNEL: boolean;
  40289. REFLECTIONFRESNEL: boolean;
  40290. REFRACTIONFRESNEL: boolean;
  40291. EMISSIVEFRESNEL: boolean;
  40292. FRESNEL: boolean;
  40293. NORMAL: boolean;
  40294. UV1: boolean;
  40295. UV2: boolean;
  40296. VERTEXCOLOR: boolean;
  40297. VERTEXALPHA: boolean;
  40298. NUM_BONE_INFLUENCERS: number;
  40299. BonesPerMesh: number;
  40300. BONETEXTURE: boolean;
  40301. INSTANCES: boolean;
  40302. GLOSSINESS: boolean;
  40303. ROUGHNESS: boolean;
  40304. EMISSIVEASILLUMINATION: boolean;
  40305. LINKEMISSIVEWITHDIFFUSE: boolean;
  40306. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40307. LIGHTMAP: boolean;
  40308. LIGHTMAPDIRECTUV: number;
  40309. OBJECTSPACE_NORMALMAP: boolean;
  40310. USELIGHTMAPASSHADOWMAP: boolean;
  40311. REFLECTIONMAP_3D: boolean;
  40312. REFLECTIONMAP_SPHERICAL: boolean;
  40313. REFLECTIONMAP_PLANAR: boolean;
  40314. REFLECTIONMAP_CUBIC: boolean;
  40315. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40316. REFLECTIONMAP_PROJECTION: boolean;
  40317. REFLECTIONMAP_SKYBOX: boolean;
  40318. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40319. REFLECTIONMAP_EXPLICIT: boolean;
  40320. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40321. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40322. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40323. INVERTCUBICMAP: boolean;
  40324. LOGARITHMICDEPTH: boolean;
  40325. REFRACTION: boolean;
  40326. REFRACTIONMAP_3D: boolean;
  40327. REFLECTIONOVERALPHA: boolean;
  40328. TWOSIDEDLIGHTING: boolean;
  40329. SHADOWFLOAT: boolean;
  40330. MORPHTARGETS: boolean;
  40331. MORPHTARGETS_NORMAL: boolean;
  40332. MORPHTARGETS_TANGENT: boolean;
  40333. MORPHTARGETS_UV: boolean;
  40334. NUM_MORPH_INFLUENCERS: number;
  40335. NONUNIFORMSCALING: boolean;
  40336. PREMULTIPLYALPHA: boolean;
  40337. IMAGEPROCESSING: boolean;
  40338. VIGNETTE: boolean;
  40339. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40340. VIGNETTEBLENDMODEOPAQUE: boolean;
  40341. TONEMAPPING: boolean;
  40342. TONEMAPPING_ACES: boolean;
  40343. CONTRAST: boolean;
  40344. COLORCURVES: boolean;
  40345. COLORGRADING: boolean;
  40346. COLORGRADING3D: boolean;
  40347. SAMPLER3DGREENDEPTH: boolean;
  40348. SAMPLER3DBGRMAP: boolean;
  40349. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40350. MULTIVIEW: boolean;
  40351. /**
  40352. * If the reflection texture on this material is in linear color space
  40353. * @hidden
  40354. */
  40355. IS_REFLECTION_LINEAR: boolean;
  40356. /**
  40357. * If the refraction texture on this material is in linear color space
  40358. * @hidden
  40359. */
  40360. IS_REFRACTION_LINEAR: boolean;
  40361. EXPOSURE: boolean;
  40362. constructor();
  40363. setReflectionMode(modeToEnable: string): void;
  40364. }
  40365. /**
  40366. * This is the default material used in Babylon. It is the best trade off between quality
  40367. * and performances.
  40368. * @see http://doc.babylonjs.com/babylon101/materials
  40369. */
  40370. export class StandardMaterial extends PushMaterial {
  40371. private _diffuseTexture;
  40372. /**
  40373. * The basic texture of the material as viewed under a light.
  40374. */
  40375. diffuseTexture: Nullable<BaseTexture>;
  40376. private _ambientTexture;
  40377. /**
  40378. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40379. */
  40380. ambientTexture: Nullable<BaseTexture>;
  40381. private _opacityTexture;
  40382. /**
  40383. * Define the transparency of the material from a texture.
  40384. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40385. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40386. */
  40387. opacityTexture: Nullable<BaseTexture>;
  40388. private _reflectionTexture;
  40389. /**
  40390. * Define the texture used to display the reflection.
  40391. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40392. */
  40393. reflectionTexture: Nullable<BaseTexture>;
  40394. private _emissiveTexture;
  40395. /**
  40396. * Define texture of the material as if self lit.
  40397. * This will be mixed in the final result even in the absence of light.
  40398. */
  40399. emissiveTexture: Nullable<BaseTexture>;
  40400. private _specularTexture;
  40401. /**
  40402. * Define how the color and intensity of the highlight given by the light in the material.
  40403. */
  40404. specularTexture: Nullable<BaseTexture>;
  40405. private _bumpTexture;
  40406. /**
  40407. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40408. * 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.
  40409. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40410. */
  40411. bumpTexture: Nullable<BaseTexture>;
  40412. private _lightmapTexture;
  40413. /**
  40414. * Complex lighting can be computationally expensive to compute at runtime.
  40415. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40416. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40417. */
  40418. lightmapTexture: Nullable<BaseTexture>;
  40419. private _refractionTexture;
  40420. /**
  40421. * Define the texture used to display the refraction.
  40422. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40423. */
  40424. refractionTexture: Nullable<BaseTexture>;
  40425. /**
  40426. * The color of the material lit by the environmental background lighting.
  40427. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40428. */
  40429. ambientColor: Color3;
  40430. /**
  40431. * The basic color of the material as viewed under a light.
  40432. */
  40433. diffuseColor: Color3;
  40434. /**
  40435. * Define how the color and intensity of the highlight given by the light in the material.
  40436. */
  40437. specularColor: Color3;
  40438. /**
  40439. * Define the color of the material as if self lit.
  40440. * This will be mixed in the final result even in the absence of light.
  40441. */
  40442. emissiveColor: Color3;
  40443. /**
  40444. * Defines how sharp are the highlights in the material.
  40445. * The bigger the value the sharper giving a more glossy feeling to the result.
  40446. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40447. */
  40448. specularPower: number;
  40449. private _useAlphaFromDiffuseTexture;
  40450. /**
  40451. * Does the transparency come from the diffuse texture alpha channel.
  40452. */
  40453. useAlphaFromDiffuseTexture: boolean;
  40454. private _useEmissiveAsIllumination;
  40455. /**
  40456. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40457. */
  40458. useEmissiveAsIllumination: boolean;
  40459. private _linkEmissiveWithDiffuse;
  40460. /**
  40461. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40462. * the emissive level when the final color is close to one.
  40463. */
  40464. linkEmissiveWithDiffuse: boolean;
  40465. private _useSpecularOverAlpha;
  40466. /**
  40467. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40468. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40469. */
  40470. useSpecularOverAlpha: boolean;
  40471. private _useReflectionOverAlpha;
  40472. /**
  40473. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40474. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40475. */
  40476. useReflectionOverAlpha: boolean;
  40477. private _disableLighting;
  40478. /**
  40479. * Does lights from the scene impacts this material.
  40480. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40481. */
  40482. disableLighting: boolean;
  40483. private _useObjectSpaceNormalMap;
  40484. /**
  40485. * Allows using an object space normal map (instead of tangent space).
  40486. */
  40487. useObjectSpaceNormalMap: boolean;
  40488. private _useParallax;
  40489. /**
  40490. * Is parallax enabled or not.
  40491. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40492. */
  40493. useParallax: boolean;
  40494. private _useParallaxOcclusion;
  40495. /**
  40496. * Is parallax occlusion enabled or not.
  40497. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40498. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40499. */
  40500. useParallaxOcclusion: boolean;
  40501. /**
  40502. * 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.
  40503. */
  40504. parallaxScaleBias: number;
  40505. private _roughness;
  40506. /**
  40507. * Helps to define how blurry the reflections should appears in the material.
  40508. */
  40509. roughness: number;
  40510. /**
  40511. * In case of refraction, define the value of the index of refraction.
  40512. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40513. */
  40514. indexOfRefraction: number;
  40515. /**
  40516. * Invert the refraction texture alongside the y axis.
  40517. * It can be useful with procedural textures or probe for instance.
  40518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40519. */
  40520. invertRefractionY: boolean;
  40521. /**
  40522. * Defines the alpha limits in alpha test mode.
  40523. */
  40524. alphaCutOff: number;
  40525. private _useLightmapAsShadowmap;
  40526. /**
  40527. * In case of light mapping, define whether the map contains light or shadow informations.
  40528. */
  40529. useLightmapAsShadowmap: boolean;
  40530. private _diffuseFresnelParameters;
  40531. /**
  40532. * Define the diffuse fresnel parameters of the material.
  40533. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40534. */
  40535. diffuseFresnelParameters: FresnelParameters;
  40536. private _opacityFresnelParameters;
  40537. /**
  40538. * Define the opacity fresnel parameters of the material.
  40539. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40540. */
  40541. opacityFresnelParameters: FresnelParameters;
  40542. private _reflectionFresnelParameters;
  40543. /**
  40544. * Define the reflection fresnel parameters of the material.
  40545. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40546. */
  40547. reflectionFresnelParameters: FresnelParameters;
  40548. private _refractionFresnelParameters;
  40549. /**
  40550. * Define the refraction fresnel parameters of the material.
  40551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40552. */
  40553. refractionFresnelParameters: FresnelParameters;
  40554. private _emissiveFresnelParameters;
  40555. /**
  40556. * Define the emissive fresnel parameters of the material.
  40557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40558. */
  40559. emissiveFresnelParameters: FresnelParameters;
  40560. private _useReflectionFresnelFromSpecular;
  40561. /**
  40562. * If true automatically deducts the fresnels values from the material specularity.
  40563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40564. */
  40565. useReflectionFresnelFromSpecular: boolean;
  40566. private _useGlossinessFromSpecularMapAlpha;
  40567. /**
  40568. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40569. */
  40570. useGlossinessFromSpecularMapAlpha: boolean;
  40571. private _maxSimultaneousLights;
  40572. /**
  40573. * Defines the maximum number of lights that can be used in the material
  40574. */
  40575. maxSimultaneousLights: number;
  40576. private _invertNormalMapX;
  40577. /**
  40578. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40579. */
  40580. invertNormalMapX: boolean;
  40581. private _invertNormalMapY;
  40582. /**
  40583. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40584. */
  40585. invertNormalMapY: boolean;
  40586. private _twoSidedLighting;
  40587. /**
  40588. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40589. */
  40590. twoSidedLighting: boolean;
  40591. /**
  40592. * Default configuration related to image processing available in the standard Material.
  40593. */
  40594. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40595. /**
  40596. * Gets the image processing configuration used either in this material.
  40597. */
  40598. /**
  40599. * Sets the Default image processing configuration used either in the this material.
  40600. *
  40601. * If sets to null, the scene one is in use.
  40602. */
  40603. imageProcessingConfiguration: ImageProcessingConfiguration;
  40604. /**
  40605. * Keep track of the image processing observer to allow dispose and replace.
  40606. */
  40607. private _imageProcessingObserver;
  40608. /**
  40609. * Attaches a new image processing configuration to the Standard Material.
  40610. * @param configuration
  40611. */
  40612. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40613. /**
  40614. * Gets wether the color curves effect is enabled.
  40615. */
  40616. /**
  40617. * Sets wether the color curves effect is enabled.
  40618. */
  40619. cameraColorCurvesEnabled: boolean;
  40620. /**
  40621. * Gets wether the color grading effect is enabled.
  40622. */
  40623. /**
  40624. * Gets wether the color grading effect is enabled.
  40625. */
  40626. cameraColorGradingEnabled: boolean;
  40627. /**
  40628. * Gets wether tonemapping is enabled or not.
  40629. */
  40630. /**
  40631. * Sets wether tonemapping is enabled or not
  40632. */
  40633. cameraToneMappingEnabled: boolean;
  40634. /**
  40635. * The camera exposure used on this material.
  40636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40637. * This corresponds to a photographic exposure.
  40638. */
  40639. /**
  40640. * The camera exposure used on this material.
  40641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40642. * This corresponds to a photographic exposure.
  40643. */
  40644. cameraExposure: number;
  40645. /**
  40646. * Gets The camera contrast used on this material.
  40647. */
  40648. /**
  40649. * Sets The camera contrast used on this material.
  40650. */
  40651. cameraContrast: number;
  40652. /**
  40653. * Gets the Color Grading 2D Lookup Texture.
  40654. */
  40655. /**
  40656. * Sets the Color Grading 2D Lookup Texture.
  40657. */
  40658. cameraColorGradingTexture: Nullable<BaseTexture>;
  40659. /**
  40660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40662. * 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;
  40663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40664. */
  40665. /**
  40666. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40667. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40668. * 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;
  40669. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40670. */
  40671. cameraColorCurves: Nullable<ColorCurves>;
  40672. /**
  40673. * Custom callback helping to override the default shader used in the material.
  40674. */
  40675. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40676. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40677. protected _worldViewProjectionMatrix: Matrix;
  40678. protected _globalAmbientColor: Color3;
  40679. protected _useLogarithmicDepth: boolean;
  40680. protected _rebuildInParallel: boolean;
  40681. /**
  40682. * Instantiates a new standard material.
  40683. * This is the default material used in Babylon. It is the best trade off between quality
  40684. * and performances.
  40685. * @see http://doc.babylonjs.com/babylon101/materials
  40686. * @param name Define the name of the material in the scene
  40687. * @param scene Define the scene the material belong to
  40688. */
  40689. constructor(name: string, scene: Scene);
  40690. /**
  40691. * Gets a boolean indicating that current material needs to register RTT
  40692. */
  40693. readonly hasRenderTargetTextures: boolean;
  40694. /**
  40695. * Gets the current class name of the material e.g. "StandardMaterial"
  40696. * Mainly use in serialization.
  40697. * @returns the class name
  40698. */
  40699. getClassName(): string;
  40700. /**
  40701. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40702. * You can try switching to logarithmic depth.
  40703. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40704. */
  40705. useLogarithmicDepth: boolean;
  40706. /**
  40707. * Specifies if the material will require alpha blending
  40708. * @returns a boolean specifying if alpha blending is needed
  40709. */
  40710. needAlphaBlending(): boolean;
  40711. /**
  40712. * Specifies if this material should be rendered in alpha test mode
  40713. * @returns a boolean specifying if an alpha test is needed.
  40714. */
  40715. needAlphaTesting(): boolean;
  40716. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40717. /**
  40718. * Get the texture used for alpha test purpose.
  40719. * @returns the diffuse texture in case of the standard material.
  40720. */
  40721. getAlphaTestTexture(): Nullable<BaseTexture>;
  40722. /**
  40723. * Get if the submesh is ready to be used and all its information available.
  40724. * Child classes can use it to update shaders
  40725. * @param mesh defines the mesh to check
  40726. * @param subMesh defines which submesh to check
  40727. * @param useInstances specifies that instances should be used
  40728. * @returns a boolean indicating that the submesh is ready or not
  40729. */
  40730. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40731. /**
  40732. * Builds the material UBO layouts.
  40733. * Used internally during the effect preparation.
  40734. */
  40735. buildUniformLayout(): void;
  40736. /**
  40737. * Unbinds the material from the mesh
  40738. */
  40739. unbind(): void;
  40740. /**
  40741. * Binds the submesh to this material by preparing the effect and shader to draw
  40742. * @param world defines the world transformation matrix
  40743. * @param mesh defines the mesh containing the submesh
  40744. * @param subMesh defines the submesh to bind the material to
  40745. */
  40746. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40747. /**
  40748. * Get the list of animatables in the material.
  40749. * @returns the list of animatables object used in the material
  40750. */
  40751. getAnimatables(): IAnimatable[];
  40752. /**
  40753. * Gets the active textures from the material
  40754. * @returns an array of textures
  40755. */
  40756. getActiveTextures(): BaseTexture[];
  40757. /**
  40758. * Specifies if the material uses a texture
  40759. * @param texture defines the texture to check against the material
  40760. * @returns a boolean specifying if the material uses the texture
  40761. */
  40762. hasTexture(texture: BaseTexture): boolean;
  40763. /**
  40764. * Disposes the material
  40765. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40766. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40767. */
  40768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40769. /**
  40770. * Makes a duplicate of the material, and gives it a new name
  40771. * @param name defines the new name for the duplicated material
  40772. * @returns the cloned material
  40773. */
  40774. clone(name: string): StandardMaterial;
  40775. /**
  40776. * Serializes this material in a JSON representation
  40777. * @returns the serialized material object
  40778. */
  40779. serialize(): any;
  40780. /**
  40781. * Creates a standard material from parsed material data
  40782. * @param source defines the JSON representation of the material
  40783. * @param scene defines the hosting scene
  40784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40785. * @returns a new standard material
  40786. */
  40787. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40788. /**
  40789. * Are diffuse textures enabled in the application.
  40790. */
  40791. static DiffuseTextureEnabled: boolean;
  40792. /**
  40793. * Are ambient textures enabled in the application.
  40794. */
  40795. static AmbientTextureEnabled: boolean;
  40796. /**
  40797. * Are opacity textures enabled in the application.
  40798. */
  40799. static OpacityTextureEnabled: boolean;
  40800. /**
  40801. * Are reflection textures enabled in the application.
  40802. */
  40803. static ReflectionTextureEnabled: boolean;
  40804. /**
  40805. * Are emissive textures enabled in the application.
  40806. */
  40807. static EmissiveTextureEnabled: boolean;
  40808. /**
  40809. * Are specular textures enabled in the application.
  40810. */
  40811. static SpecularTextureEnabled: boolean;
  40812. /**
  40813. * Are bump textures enabled in the application.
  40814. */
  40815. static BumpTextureEnabled: boolean;
  40816. /**
  40817. * Are lightmap textures enabled in the application.
  40818. */
  40819. static LightmapTextureEnabled: boolean;
  40820. /**
  40821. * Are refraction textures enabled in the application.
  40822. */
  40823. static RefractionTextureEnabled: boolean;
  40824. /**
  40825. * Are color grading textures enabled in the application.
  40826. */
  40827. static ColorGradingTextureEnabled: boolean;
  40828. /**
  40829. * Are fresnels enabled in the application.
  40830. */
  40831. static FresnelEnabled: boolean;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /** @hidden */
  40836. export var imageProcessingPixelShader: {
  40837. name: string;
  40838. shader: string;
  40839. };
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * ImageProcessingPostProcess
  40844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40845. */
  40846. export class ImageProcessingPostProcess extends PostProcess {
  40847. /**
  40848. * Default configuration related to image processing available in the PBR Material.
  40849. */
  40850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40851. /**
  40852. * Gets the image processing configuration used either in this material.
  40853. */
  40854. /**
  40855. * Sets the Default image processing configuration used either in the this material.
  40856. *
  40857. * If sets to null, the scene one is in use.
  40858. */
  40859. imageProcessingConfiguration: ImageProcessingConfiguration;
  40860. /**
  40861. * Keep track of the image processing observer to allow dispose and replace.
  40862. */
  40863. private _imageProcessingObserver;
  40864. /**
  40865. * Attaches a new image processing configuration to the PBR Material.
  40866. * @param configuration
  40867. */
  40868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40869. /**
  40870. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40871. */
  40872. /**
  40873. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40874. */
  40875. colorCurves: Nullable<ColorCurves>;
  40876. /**
  40877. * Gets wether the color curves effect is enabled.
  40878. */
  40879. /**
  40880. * Sets wether the color curves effect is enabled.
  40881. */
  40882. colorCurvesEnabled: boolean;
  40883. /**
  40884. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40885. */
  40886. /**
  40887. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40888. */
  40889. colorGradingTexture: Nullable<BaseTexture>;
  40890. /**
  40891. * Gets wether the color grading effect is enabled.
  40892. */
  40893. /**
  40894. * Gets wether the color grading effect is enabled.
  40895. */
  40896. colorGradingEnabled: boolean;
  40897. /**
  40898. * Gets exposure used in the effect.
  40899. */
  40900. /**
  40901. * Sets exposure used in the effect.
  40902. */
  40903. exposure: number;
  40904. /**
  40905. * Gets wether tonemapping is enabled or not.
  40906. */
  40907. /**
  40908. * Sets wether tonemapping is enabled or not
  40909. */
  40910. toneMappingEnabled: boolean;
  40911. /**
  40912. * Gets the type of tone mapping effect.
  40913. */
  40914. /**
  40915. * Sets the type of tone mapping effect.
  40916. */
  40917. toneMappingType: number;
  40918. /**
  40919. * Gets contrast used in the effect.
  40920. */
  40921. /**
  40922. * Sets contrast used in the effect.
  40923. */
  40924. contrast: number;
  40925. /**
  40926. * Gets Vignette stretch size.
  40927. */
  40928. /**
  40929. * Sets Vignette stretch size.
  40930. */
  40931. vignetteStretch: number;
  40932. /**
  40933. * Gets Vignette centre X Offset.
  40934. */
  40935. /**
  40936. * Sets Vignette centre X Offset.
  40937. */
  40938. vignetteCentreX: number;
  40939. /**
  40940. * Gets Vignette centre Y Offset.
  40941. */
  40942. /**
  40943. * Sets Vignette centre Y Offset.
  40944. */
  40945. vignetteCentreY: number;
  40946. /**
  40947. * Gets Vignette weight or intensity of the vignette effect.
  40948. */
  40949. /**
  40950. * Sets Vignette weight or intensity of the vignette effect.
  40951. */
  40952. vignetteWeight: number;
  40953. /**
  40954. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40955. * if vignetteEnabled is set to true.
  40956. */
  40957. /**
  40958. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40959. * if vignetteEnabled is set to true.
  40960. */
  40961. vignetteColor: Color4;
  40962. /**
  40963. * Gets Camera field of view used by the Vignette effect.
  40964. */
  40965. /**
  40966. * Sets Camera field of view used by the Vignette effect.
  40967. */
  40968. vignetteCameraFov: number;
  40969. /**
  40970. * Gets the vignette blend mode allowing different kind of effect.
  40971. */
  40972. /**
  40973. * Sets the vignette blend mode allowing different kind of effect.
  40974. */
  40975. vignetteBlendMode: number;
  40976. /**
  40977. * Gets wether the vignette effect is enabled.
  40978. */
  40979. /**
  40980. * Sets wether the vignette effect is enabled.
  40981. */
  40982. vignetteEnabled: boolean;
  40983. private _fromLinearSpace;
  40984. /**
  40985. * Gets wether the input of the processing is in Gamma or Linear Space.
  40986. */
  40987. /**
  40988. * Sets wether the input of the processing is in Gamma or Linear Space.
  40989. */
  40990. fromLinearSpace: boolean;
  40991. /**
  40992. * Defines cache preventing GC.
  40993. */
  40994. private _defines;
  40995. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40996. /**
  40997. * "ImageProcessingPostProcess"
  40998. * @returns "ImageProcessingPostProcess"
  40999. */
  41000. getClassName(): string;
  41001. protected _updateParameters(): void;
  41002. dispose(camera?: Camera): void;
  41003. }
  41004. }
  41005. declare module BABYLON {
  41006. /**
  41007. * Class containing static functions to help procedurally build meshes
  41008. */
  41009. export class GroundBuilder {
  41010. /**
  41011. * Creates a ground mesh
  41012. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41013. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41015. * @param name defines the name of the mesh
  41016. * @param options defines the options used to create the mesh
  41017. * @param scene defines the hosting scene
  41018. * @returns the ground mesh
  41019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41020. */
  41021. static CreateGround(name: string, options: {
  41022. width?: number;
  41023. height?: number;
  41024. subdivisions?: number;
  41025. subdivisionsX?: number;
  41026. subdivisionsY?: number;
  41027. updatable?: boolean;
  41028. }, scene: any): Mesh;
  41029. /**
  41030. * Creates a tiled ground mesh
  41031. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41032. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41033. * * 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
  41034. * * 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
  41035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41036. * @param name defines the name of the mesh
  41037. * @param options defines the options used to create the mesh
  41038. * @param scene defines the hosting scene
  41039. * @returns the tiled ground mesh
  41040. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41041. */
  41042. static CreateTiledGround(name: string, options: {
  41043. xmin: number;
  41044. zmin: number;
  41045. xmax: number;
  41046. zmax: number;
  41047. subdivisions?: {
  41048. w: number;
  41049. h: number;
  41050. };
  41051. precision?: {
  41052. w: number;
  41053. h: number;
  41054. };
  41055. updatable?: boolean;
  41056. }, scene?: Nullable<Scene>): Mesh;
  41057. /**
  41058. * Creates a ground mesh from a height map
  41059. * * The parameter `url` sets the URL of the height map image resource.
  41060. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41061. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41062. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41063. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41064. * * 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.
  41065. * * 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).
  41066. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41068. * @param name defines the name of the mesh
  41069. * @param url defines the url to the height map
  41070. * @param options defines the options used to create the mesh
  41071. * @param scene defines the hosting scene
  41072. * @returns the ground mesh
  41073. * @see https://doc.babylonjs.com/babylon101/height_map
  41074. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41075. */
  41076. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41077. width?: number;
  41078. height?: number;
  41079. subdivisions?: number;
  41080. minHeight?: number;
  41081. maxHeight?: number;
  41082. colorFilter?: Color3;
  41083. alphaFilter?: number;
  41084. updatable?: boolean;
  41085. onReady?: (mesh: GroundMesh) => void;
  41086. }, scene?: Nullable<Scene>): GroundMesh;
  41087. }
  41088. }
  41089. declare module BABYLON {
  41090. /**
  41091. * Class containing static functions to help procedurally build meshes
  41092. */
  41093. export class TorusBuilder {
  41094. /**
  41095. * Creates a torus mesh
  41096. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41097. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41098. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41100. * * 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
  41101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41102. * @param name defines the name of the mesh
  41103. * @param options defines the options used to create the mesh
  41104. * @param scene defines the hosting scene
  41105. * @returns the torus mesh
  41106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41107. */
  41108. static CreateTorus(name: string, options: {
  41109. diameter?: number;
  41110. thickness?: number;
  41111. tessellation?: number;
  41112. updatable?: boolean;
  41113. sideOrientation?: number;
  41114. frontUVs?: Vector4;
  41115. backUVs?: Vector4;
  41116. }, scene: any): Mesh;
  41117. }
  41118. }
  41119. declare module BABYLON {
  41120. /**
  41121. * Class containing static functions to help procedurally build meshes
  41122. */
  41123. export class CylinderBuilder {
  41124. /**
  41125. * Creates a cylinder or a cone mesh
  41126. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41127. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41128. * * 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.
  41129. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41130. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41131. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41132. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41133. * * 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).
  41134. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41135. * * 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).
  41136. * * 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
  41137. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41138. * * 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
  41139. * * 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.
  41140. * * If `enclose` is false, a ring surface is one element.
  41141. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41142. * * 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
  41143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41144. * * 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
  41145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41146. * @param name defines the name of the mesh
  41147. * @param options defines the options used to create the mesh
  41148. * @param scene defines the hosting scene
  41149. * @returns the cylinder mesh
  41150. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41151. */
  41152. static CreateCylinder(name: string, options: {
  41153. height?: number;
  41154. diameterTop?: number;
  41155. diameterBottom?: number;
  41156. diameter?: number;
  41157. tessellation?: number;
  41158. subdivisions?: number;
  41159. arc?: number;
  41160. faceColors?: Color4[];
  41161. faceUV?: Vector4[];
  41162. updatable?: boolean;
  41163. hasRings?: boolean;
  41164. enclose?: boolean;
  41165. cap?: number;
  41166. sideOrientation?: number;
  41167. frontUVs?: Vector4;
  41168. backUVs?: Vector4;
  41169. }, scene: any): Mesh;
  41170. }
  41171. }
  41172. declare module BABYLON {
  41173. /**
  41174. * Options to modify the vr teleportation behavior.
  41175. */
  41176. export interface VRTeleportationOptions {
  41177. /**
  41178. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41179. */
  41180. floorMeshName?: string;
  41181. /**
  41182. * A list of meshes to be used as the teleportation floor. (default: empty)
  41183. */
  41184. floorMeshes?: Mesh[];
  41185. }
  41186. /**
  41187. * Options to modify the vr experience helper's behavior.
  41188. */
  41189. export interface VRExperienceHelperOptions extends WebVROptions {
  41190. /**
  41191. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41192. */
  41193. createDeviceOrientationCamera?: boolean;
  41194. /**
  41195. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41196. */
  41197. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41198. /**
  41199. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41200. */
  41201. laserToggle?: boolean;
  41202. /**
  41203. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41204. */
  41205. floorMeshes?: Mesh[];
  41206. /**
  41207. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41208. */
  41209. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41210. }
  41211. /**
  41212. * Event containing information after VR has been entered
  41213. */
  41214. export class OnAfterEnteringVRObservableEvent {
  41215. /**
  41216. * If entering vr was successful
  41217. */
  41218. success: boolean;
  41219. }
  41220. /**
  41221. * Helps to quickly add VR support to an existing scene.
  41222. * See http://doc.babylonjs.com/how_to/webvr_helper
  41223. */
  41224. export class VRExperienceHelper {
  41225. /** Options to modify the vr experience helper's behavior. */
  41226. webVROptions: VRExperienceHelperOptions;
  41227. private _scene;
  41228. private _position;
  41229. private _btnVR;
  41230. private _btnVRDisplayed;
  41231. private _webVRsupported;
  41232. private _webVRready;
  41233. private _webVRrequesting;
  41234. private _webVRpresenting;
  41235. private _hasEnteredVR;
  41236. private _fullscreenVRpresenting;
  41237. private _canvas;
  41238. private _webVRCamera;
  41239. private _vrDeviceOrientationCamera;
  41240. private _deviceOrientationCamera;
  41241. private _existingCamera;
  41242. private _onKeyDown;
  41243. private _onVrDisplayPresentChange;
  41244. private _onVRDisplayChanged;
  41245. private _onVRRequestPresentStart;
  41246. private _onVRRequestPresentComplete;
  41247. /**
  41248. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41249. */
  41250. enableGazeEvenWhenNoPointerLock: boolean;
  41251. /**
  41252. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41253. */
  41254. exitVROnDoubleTap: boolean;
  41255. /**
  41256. * Observable raised right before entering VR.
  41257. */
  41258. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41259. /**
  41260. * Observable raised when entering VR has completed.
  41261. */
  41262. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41263. /**
  41264. * Observable raised when exiting VR.
  41265. */
  41266. onExitingVRObservable: Observable<VRExperienceHelper>;
  41267. /**
  41268. * Observable raised when controller mesh is loaded.
  41269. */
  41270. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41271. /** Return this.onEnteringVRObservable
  41272. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41273. */
  41274. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41275. /** Return this.onExitingVRObservable
  41276. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41277. */
  41278. readonly onExitingVR: Observable<VRExperienceHelper>;
  41279. /** Return this.onControllerMeshLoadedObservable
  41280. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41281. */
  41282. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41283. private _rayLength;
  41284. private _useCustomVRButton;
  41285. private _teleportationRequested;
  41286. private _teleportActive;
  41287. private _floorMeshName;
  41288. private _floorMeshesCollection;
  41289. private _rotationAllowed;
  41290. private _teleportBackwardsVector;
  41291. private _teleportationTarget;
  41292. private _isDefaultTeleportationTarget;
  41293. private _postProcessMove;
  41294. private _teleportationFillColor;
  41295. private _teleportationBorderColor;
  41296. private _rotationAngle;
  41297. private _haloCenter;
  41298. private _cameraGazer;
  41299. private _padSensibilityUp;
  41300. private _padSensibilityDown;
  41301. private _leftController;
  41302. private _rightController;
  41303. /**
  41304. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41305. */
  41306. onNewMeshSelected: Observable<AbstractMesh>;
  41307. /**
  41308. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41309. * This observable will provide the mesh and the controller used to select the mesh
  41310. */
  41311. onMeshSelectedWithController: Observable<{
  41312. mesh: AbstractMesh;
  41313. controller: WebVRController;
  41314. }>;
  41315. /**
  41316. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41317. */
  41318. onNewMeshPicked: Observable<PickingInfo>;
  41319. private _circleEase;
  41320. /**
  41321. * Observable raised before camera teleportation
  41322. */
  41323. onBeforeCameraTeleport: Observable<Vector3>;
  41324. /**
  41325. * Observable raised after camera teleportation
  41326. */
  41327. onAfterCameraTeleport: Observable<Vector3>;
  41328. /**
  41329. * Observable raised when current selected mesh gets unselected
  41330. */
  41331. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41332. private _raySelectionPredicate;
  41333. /**
  41334. * To be optionaly changed by user to define custom ray selection
  41335. */
  41336. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41337. /**
  41338. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41339. */
  41340. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41341. /**
  41342. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41343. */
  41344. teleportationEnabled: boolean;
  41345. private _defaultHeight;
  41346. private _teleportationInitialized;
  41347. private _interactionsEnabled;
  41348. private _interactionsRequested;
  41349. private _displayGaze;
  41350. private _displayLaserPointer;
  41351. /**
  41352. * The mesh used to display where the user is going to teleport.
  41353. */
  41354. /**
  41355. * Sets the mesh to be used to display where the user is going to teleport.
  41356. */
  41357. teleportationTarget: Mesh;
  41358. /**
  41359. * 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
  41360. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41361. * See http://doc.babylonjs.com/resources/baking_transformations
  41362. */
  41363. gazeTrackerMesh: Mesh;
  41364. /**
  41365. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41366. */
  41367. updateGazeTrackerScale: boolean;
  41368. /**
  41369. * If the gaze trackers color should be updated when selecting meshes
  41370. */
  41371. updateGazeTrackerColor: boolean;
  41372. /**
  41373. * If the controller laser color should be updated when selecting meshes
  41374. */
  41375. updateControllerLaserColor: boolean;
  41376. /**
  41377. * The gaze tracking mesh corresponding to the left controller
  41378. */
  41379. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41380. /**
  41381. * The gaze tracking mesh corresponding to the right controller
  41382. */
  41383. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41384. /**
  41385. * If the ray of the gaze should be displayed.
  41386. */
  41387. /**
  41388. * Sets if the ray of the gaze should be displayed.
  41389. */
  41390. displayGaze: boolean;
  41391. /**
  41392. * If the ray of the LaserPointer should be displayed.
  41393. */
  41394. /**
  41395. * Sets if the ray of the LaserPointer should be displayed.
  41396. */
  41397. displayLaserPointer: boolean;
  41398. /**
  41399. * The deviceOrientationCamera used as the camera when not in VR.
  41400. */
  41401. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41402. /**
  41403. * Based on the current WebVR support, returns the current VR camera used.
  41404. */
  41405. readonly currentVRCamera: Nullable<Camera>;
  41406. /**
  41407. * The webVRCamera which is used when in VR.
  41408. */
  41409. readonly webVRCamera: WebVRFreeCamera;
  41410. /**
  41411. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41412. */
  41413. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41414. /**
  41415. * The html button that is used to trigger entering into VR.
  41416. */
  41417. readonly vrButton: Nullable<HTMLButtonElement>;
  41418. private readonly _teleportationRequestInitiated;
  41419. /**
  41420. * Defines wether or not Pointer lock should be requested when switching to
  41421. * full screen.
  41422. */
  41423. requestPointerLockOnFullScreen: boolean;
  41424. /**
  41425. * Instantiates a VRExperienceHelper.
  41426. * Helps to quickly add VR support to an existing scene.
  41427. * @param scene The scene the VRExperienceHelper belongs to.
  41428. * @param webVROptions Options to modify the vr experience helper's behavior.
  41429. */
  41430. constructor(scene: Scene,
  41431. /** Options to modify the vr experience helper's behavior. */
  41432. webVROptions?: VRExperienceHelperOptions);
  41433. private _onDefaultMeshLoaded;
  41434. private _onResize;
  41435. private _onFullscreenChange;
  41436. /**
  41437. * Gets a value indicating if we are currently in VR mode.
  41438. */
  41439. readonly isInVRMode: boolean;
  41440. private onVrDisplayPresentChange;
  41441. private onVRDisplayChanged;
  41442. private moveButtonToBottomRight;
  41443. private displayVRButton;
  41444. private updateButtonVisibility;
  41445. private _cachedAngularSensibility;
  41446. /**
  41447. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41448. * Otherwise, will use the fullscreen API.
  41449. */
  41450. enterVR(): void;
  41451. /**
  41452. * Attempt to exit VR, or fullscreen.
  41453. */
  41454. exitVR(): void;
  41455. /**
  41456. * The position of the vr experience helper.
  41457. */
  41458. /**
  41459. * Sets the position of the vr experience helper.
  41460. */
  41461. position: Vector3;
  41462. /**
  41463. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41464. */
  41465. enableInteractions(): void;
  41466. private readonly _noControllerIsActive;
  41467. private beforeRender;
  41468. private _isTeleportationFloor;
  41469. /**
  41470. * Adds a floor mesh to be used for teleportation.
  41471. * @param floorMesh the mesh to be used for teleportation.
  41472. */
  41473. addFloorMesh(floorMesh: Mesh): void;
  41474. /**
  41475. * Removes a floor mesh from being used for teleportation.
  41476. * @param floorMesh the mesh to be removed.
  41477. */
  41478. removeFloorMesh(floorMesh: Mesh): void;
  41479. /**
  41480. * Enables interactions and teleportation using the VR controllers and gaze.
  41481. * @param vrTeleportationOptions options to modify teleportation behavior.
  41482. */
  41483. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41484. private _onNewGamepadConnected;
  41485. private _tryEnableInteractionOnController;
  41486. private _onNewGamepadDisconnected;
  41487. private _enableInteractionOnController;
  41488. private _checkTeleportWithRay;
  41489. private _checkRotate;
  41490. private _checkTeleportBackwards;
  41491. private _enableTeleportationOnController;
  41492. private _createTeleportationCircles;
  41493. private _displayTeleportationTarget;
  41494. private _hideTeleportationTarget;
  41495. private _rotateCamera;
  41496. private _moveTeleportationSelectorTo;
  41497. private _workingVector;
  41498. private _workingQuaternion;
  41499. private _workingMatrix;
  41500. /**
  41501. * Teleports the users feet to the desired location
  41502. * @param location The location where the user's feet should be placed
  41503. */
  41504. teleportCamera(location: Vector3): void;
  41505. private _convertNormalToDirectionOfRay;
  41506. private _castRayAndSelectObject;
  41507. private _notifySelectedMeshUnselected;
  41508. /**
  41509. * Sets the color of the laser ray from the vr controllers.
  41510. * @param color new color for the ray.
  41511. */
  41512. changeLaserColor(color: Color3): void;
  41513. /**
  41514. * Sets the color of the ray from the vr headsets gaze.
  41515. * @param color new color for the ray.
  41516. */
  41517. changeGazeColor(color: Color3): void;
  41518. /**
  41519. * Exits VR and disposes of the vr experience helper
  41520. */
  41521. dispose(): void;
  41522. /**
  41523. * Gets the name of the VRExperienceHelper class
  41524. * @returns "VRExperienceHelper"
  41525. */
  41526. getClassName(): string;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * States of the webXR experience
  41532. */
  41533. export enum WebXRState {
  41534. /**
  41535. * Transitioning to being in XR mode
  41536. */
  41537. ENTERING_XR = 0,
  41538. /**
  41539. * Transitioning to non XR mode
  41540. */
  41541. EXITING_XR = 1,
  41542. /**
  41543. * In XR mode and presenting
  41544. */
  41545. IN_XR = 2,
  41546. /**
  41547. * Not entered XR mode
  41548. */
  41549. NOT_IN_XR = 3
  41550. }
  41551. /**
  41552. * Abstraction of the XR render target
  41553. */
  41554. export interface WebXRRenderTarget extends IDisposable {
  41555. /**
  41556. * xrpresent context of the canvas which can be used to display/mirror xr content
  41557. */
  41558. canvasContext: WebGLRenderingContext;
  41559. /**
  41560. * xr layer for the canvas
  41561. */
  41562. xrLayer: Nullable<XRWebGLLayer>;
  41563. /**
  41564. * Initializes the xr layer for the session
  41565. * @param xrSession xr session
  41566. * @returns a promise that will resolve once the XR Layer has been created
  41567. */
  41568. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41569. }
  41570. }
  41571. declare module BABYLON {
  41572. /**
  41573. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41574. */
  41575. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41576. private _engine;
  41577. private _canvas;
  41578. /**
  41579. * xrpresent context of the canvas which can be used to display/mirror xr content
  41580. */
  41581. canvasContext: WebGLRenderingContext;
  41582. /**
  41583. * xr layer for the canvas
  41584. */
  41585. xrLayer: Nullable<XRWebGLLayer>;
  41586. /**
  41587. * Initializes the xr layer for the session
  41588. * @param xrSession xr session
  41589. * @returns a promise that will resolve once the XR Layer has been created
  41590. */
  41591. initializeXRLayerAsync(xrSession: any): any;
  41592. /**
  41593. * Initializes the canvas to be added/removed upon entering/exiting xr
  41594. * @param engine the Babylon engine
  41595. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41596. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41597. */
  41598. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41599. /**
  41600. * Disposes of the object
  41601. */
  41602. dispose(): void;
  41603. private _setManagedOutputCanvas;
  41604. private _addCanvas;
  41605. private _removeCanvas;
  41606. }
  41607. }
  41608. declare module BABYLON {
  41609. /**
  41610. * Manages an XRSession to work with Babylon's engine
  41611. * @see https://doc.babylonjs.com/how_to/webxr
  41612. */
  41613. export class WebXRSessionManager implements IDisposable {
  41614. private scene;
  41615. /**
  41616. * Fires every time a new xrFrame arrives which can be used to update the camera
  41617. */
  41618. onXRFrameObservable: Observable<any>;
  41619. /**
  41620. * Fires when the xr session is ended either by the device or manually done
  41621. */
  41622. onXRSessionEnded: Observable<any>;
  41623. /**
  41624. * Underlying xr session
  41625. */
  41626. session: XRSession;
  41627. /**
  41628. * Type of reference space used when creating the session
  41629. */
  41630. referenceSpace: XRReferenceSpace;
  41631. /**
  41632. * Current XR frame
  41633. */
  41634. currentFrame: Nullable<XRFrame>;
  41635. private _xrNavigator;
  41636. private baseLayer;
  41637. private _rttProvider;
  41638. private _sessionEnded;
  41639. /**
  41640. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41641. * @param scene The scene which the session should be created for
  41642. */
  41643. constructor(scene: Scene);
  41644. /**
  41645. * Initializes the manager
  41646. * After initialization enterXR can be called to start an XR session
  41647. * @returns Promise which resolves after it is initialized
  41648. */
  41649. initializeAsync(): Promise<void>;
  41650. /**
  41651. * Initializes an xr session
  41652. * @param xrSessionMode mode to initialize
  41653. * @param optionalFeatures defines optional values to pass to the session builder
  41654. * @returns a promise which will resolve once the session has been initialized
  41655. */
  41656. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41657. /**
  41658. * Sets the reference space on the xr session
  41659. * @param referenceSpace space to set
  41660. * @returns a promise that will resolve once the reference space has been set
  41661. */
  41662. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41663. /**
  41664. * Updates the render state of the session
  41665. * @param state state to set
  41666. * @returns a promise that resolves once the render state has been updated
  41667. */
  41668. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41669. /**
  41670. * Starts rendering to the xr layer
  41671. * @returns a promise that will resolve once rendering has started
  41672. */
  41673. startRenderingToXRAsync(): Promise<void>;
  41674. /**
  41675. * Gets the correct render target texture to be rendered this frame for this eye
  41676. * @param eye the eye for which to get the render target
  41677. * @returns the render target for the specified eye
  41678. */
  41679. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41680. /**
  41681. * Stops the xrSession and restores the renderloop
  41682. * @returns Promise which resolves after it exits XR
  41683. */
  41684. exitXRAsync(): Promise<void>;
  41685. /**
  41686. * Checks if a session would be supported for the creation options specified
  41687. * @param sessionMode session mode to check if supported eg. immersive-vr
  41688. * @returns true if supported
  41689. */
  41690. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41691. /**
  41692. * Creates a WebXRRenderTarget object for the XR session
  41693. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41694. * @returns a WebXR render target to which the session can render
  41695. */
  41696. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  41697. /**
  41698. * @hidden
  41699. * Converts the render layer of xrSession to a render target
  41700. * @param session session to create render target for
  41701. * @param scene scene the new render target should be created for
  41702. */
  41703. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41704. /**
  41705. * Disposes of the session manager
  41706. */
  41707. dispose(): void;
  41708. }
  41709. }
  41710. declare module BABYLON {
  41711. /**
  41712. * WebXR Camera which holds the views for the xrSession
  41713. * @see https://doc.babylonjs.com/how_to/webxr
  41714. */
  41715. export class WebXRCamera extends FreeCamera {
  41716. private static _TmpMatrix;
  41717. /**
  41718. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41719. * @param name the name of the camera
  41720. * @param scene the scene to add the camera to
  41721. */
  41722. constructor(name: string, scene: Scene);
  41723. private _updateNumberOfRigCameras;
  41724. /** @hidden */
  41725. _updateForDualEyeDebugging(): void;
  41726. /**
  41727. * Updates the cameras position from the current pose information of the XR session
  41728. * @param xrSessionManager the session containing pose information
  41729. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41730. */
  41731. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. /**
  41736. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41737. * @see https://doc.babylonjs.com/how_to/webxr
  41738. */
  41739. export class WebXRExperienceHelper implements IDisposable {
  41740. private scene;
  41741. /**
  41742. * 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
  41743. */
  41744. container: AbstractMesh;
  41745. /**
  41746. * Camera used to render xr content
  41747. */
  41748. camera: WebXRCamera;
  41749. /**
  41750. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41751. */
  41752. state: WebXRState;
  41753. private _setState;
  41754. private static _TmpVector;
  41755. /**
  41756. * Fires when the state of the experience helper has changed
  41757. */
  41758. onStateChangedObservable: Observable<WebXRState>;
  41759. /** Session manager used to keep track of xr session */
  41760. sessionManager: WebXRSessionManager;
  41761. private _nonVRCamera;
  41762. private _originalSceneAutoClear;
  41763. private _supported;
  41764. /**
  41765. * Creates the experience helper
  41766. * @param scene the scene to attach the experience helper to
  41767. * @returns a promise for the experience helper
  41768. */
  41769. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41770. /**
  41771. * Creates a WebXRExperienceHelper
  41772. * @param scene The scene the helper should be created in
  41773. */
  41774. private constructor();
  41775. /**
  41776. * Exits XR mode and returns the scene to its original state
  41777. * @returns promise that resolves after xr mode has exited
  41778. */
  41779. exitXRAsync(): Promise<void>;
  41780. /**
  41781. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41782. * @param sessionMode options for the XR session
  41783. * @param referenceSpaceType frame of reference of the XR session
  41784. * @param renderTarget the output canvas that will be used to enter XR mode
  41785. * @returns promise that resolves after xr mode has entered
  41786. */
  41787. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41788. /**
  41789. * Updates the global position of the camera by moving the camera's container
  41790. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41791. * @param position The desired global position of the camera
  41792. */
  41793. setPositionOfCameraUsingContainer(position: Vector3): void;
  41794. /**
  41795. * Rotates the xr camera by rotating the camera's container around the camera's position
  41796. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41797. * @param rotation the desired quaternion rotation to apply to the camera
  41798. */
  41799. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41800. /**
  41801. * Disposes of the experience helper
  41802. */
  41803. dispose(): void;
  41804. }
  41805. }
  41806. declare module BABYLON {
  41807. /**
  41808. * Button which can be used to enter a different mode of XR
  41809. */
  41810. export class WebXREnterExitUIButton {
  41811. /** button element */
  41812. element: HTMLElement;
  41813. /** XR initialization options for the button */
  41814. sessionMode: XRSessionMode;
  41815. /** Reference space type */
  41816. referenceSpaceType: XRReferenceSpaceType;
  41817. /**
  41818. * Creates a WebXREnterExitUIButton
  41819. * @param element button element
  41820. * @param sessionMode XR initialization session mode
  41821. * @param referenceSpaceType the type of reference space to be used
  41822. */
  41823. constructor(
  41824. /** button element */
  41825. element: HTMLElement,
  41826. /** XR initialization options for the button */
  41827. sessionMode: XRSessionMode,
  41828. /** Reference space type */
  41829. referenceSpaceType: XRReferenceSpaceType);
  41830. /**
  41831. * Overwritable function which can be used to update the button's visuals when the state changes
  41832. * @param activeButton the current active button in the UI
  41833. */
  41834. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41835. }
  41836. /**
  41837. * Options to create the webXR UI
  41838. */
  41839. export class WebXREnterExitUIOptions {
  41840. /**
  41841. * Context to enter xr with
  41842. */
  41843. renderTarget?: Nullable<WebXRRenderTarget>;
  41844. /**
  41845. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41846. */
  41847. customButtons?: Array<WebXREnterExitUIButton>;
  41848. }
  41849. /**
  41850. * UI to allow the user to enter/exit XR mode
  41851. */
  41852. export class WebXREnterExitUI implements IDisposable {
  41853. private scene;
  41854. private _overlay;
  41855. private _buttons;
  41856. private _activeButton;
  41857. /**
  41858. * Fired every time the active button is changed.
  41859. *
  41860. * When xr is entered via a button that launches xr that button will be the callback parameter
  41861. *
  41862. * When exiting xr the callback parameter will be null)
  41863. */
  41864. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41865. /**
  41866. * Creates UI to allow the user to enter/exit XR mode
  41867. * @param scene the scene to add the ui to
  41868. * @param helper the xr experience helper to enter/exit xr with
  41869. * @param options options to configure the UI
  41870. * @returns the created ui
  41871. */
  41872. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41873. private constructor();
  41874. private _updateButtons;
  41875. /**
  41876. * Disposes of the object
  41877. */
  41878. dispose(): void;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * Represents an XR input
  41884. */
  41885. export class WebXRController {
  41886. private scene;
  41887. /** The underlying input source for the controller */
  41888. inputSource: XRInputSource;
  41889. private parentContainer;
  41890. /**
  41891. * 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
  41892. */
  41893. grip?: AbstractMesh;
  41894. /**
  41895. * Pointer which can be used to select objects or attach a visible laser to
  41896. */
  41897. pointer: AbstractMesh;
  41898. private _gamepadMode;
  41899. /**
  41900. * If available, this is the gamepad object related to this controller.
  41901. * Using this object it is possible to get click events and trackpad changes of the
  41902. * webxr controller that is currently being used.
  41903. */
  41904. gamepadController?: WebVRController;
  41905. /**
  41906. * Event that fires when the controller is removed/disposed
  41907. */
  41908. onDisposeObservable: Observable<{}>;
  41909. private _tmpMatrix;
  41910. private _tmpQuaternion;
  41911. private _tmpVector;
  41912. /**
  41913. * Creates the controller
  41914. * @see https://doc.babylonjs.com/how_to/webxr
  41915. * @param scene the scene which the controller should be associated to
  41916. * @param inputSource the underlying input source for the controller
  41917. * @param parentContainer parent that the controller meshes should be children of
  41918. */
  41919. constructor(scene: Scene,
  41920. /** The underlying input source for the controller */
  41921. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41922. /**
  41923. * Updates the controller pose based on the given XRFrame
  41924. * @param xrFrame xr frame to update the pose with
  41925. * @param referenceSpace reference space to use
  41926. */
  41927. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41928. /**
  41929. * Gets a world space ray coming from the controller
  41930. * @param result the resulting ray
  41931. */
  41932. getWorldPointerRayToRef(result: Ray): void;
  41933. /**
  41934. * Get the scene associated with this controller
  41935. * @returns the scene object
  41936. */
  41937. getScene(): Scene;
  41938. /**
  41939. * Disposes of the object
  41940. */
  41941. dispose(): void;
  41942. }
  41943. }
  41944. declare module BABYLON {
  41945. /**
  41946. * XR input used to track XR inputs such as controllers/rays
  41947. */
  41948. export class WebXRInput implements IDisposable {
  41949. /**
  41950. * Base experience the input listens to
  41951. */
  41952. baseExperience: WebXRExperienceHelper;
  41953. /**
  41954. * XR controllers being tracked
  41955. */
  41956. controllers: Array<WebXRController>;
  41957. private _frameObserver;
  41958. private _stateObserver;
  41959. /**
  41960. * Event when a controller has been connected/added
  41961. */
  41962. onControllerAddedObservable: Observable<WebXRController>;
  41963. /**
  41964. * Event when a controller has been removed/disconnected
  41965. */
  41966. onControllerRemovedObservable: Observable<WebXRController>;
  41967. /**
  41968. * Initializes the WebXRInput
  41969. * @param baseExperience experience helper which the input should be created for
  41970. */
  41971. constructor(
  41972. /**
  41973. * Base experience the input listens to
  41974. */
  41975. baseExperience: WebXRExperienceHelper);
  41976. private _onInputSourcesChange;
  41977. private _addAndRemoveControllers;
  41978. /**
  41979. * Disposes of the object
  41980. */
  41981. dispose(): void;
  41982. }
  41983. }
  41984. declare module BABYLON {
  41985. /**
  41986. * Enables teleportation
  41987. */
  41988. export class WebXRControllerTeleportation {
  41989. private _teleportationFillColor;
  41990. private _teleportationBorderColor;
  41991. private _tmpRay;
  41992. private _tmpVector;
  41993. /**
  41994. * Creates a WebXRControllerTeleportation
  41995. * @param input input manager to add teleportation to
  41996. * @param floorMeshes floormeshes which can be teleported to
  41997. */
  41998. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /**
  42003. * Handles pointer input automatically for the pointer of XR controllers
  42004. */
  42005. export class WebXRControllerPointerSelection {
  42006. private static _idCounter;
  42007. private _tmpRay;
  42008. /**
  42009. * Creates a WebXRControllerPointerSelection
  42010. * @param input input manager to setup pointer selection
  42011. */
  42012. constructor(input: WebXRInput);
  42013. private _convertNormalToDirectionOfRay;
  42014. private _updatePointerDistance;
  42015. }
  42016. }
  42017. declare module BABYLON {
  42018. /**
  42019. * Class used to represent data loading progression
  42020. */
  42021. export class SceneLoaderProgressEvent {
  42022. /** defines if data length to load can be evaluated */
  42023. readonly lengthComputable: boolean;
  42024. /** defines the loaded data length */
  42025. readonly loaded: number;
  42026. /** defines the data length to load */
  42027. readonly total: number;
  42028. /**
  42029. * Create a new progress event
  42030. * @param lengthComputable defines if data length to load can be evaluated
  42031. * @param loaded defines the loaded data length
  42032. * @param total defines the data length to load
  42033. */
  42034. constructor(
  42035. /** defines if data length to load can be evaluated */
  42036. lengthComputable: boolean,
  42037. /** defines the loaded data length */
  42038. loaded: number,
  42039. /** defines the data length to load */
  42040. total: number);
  42041. /**
  42042. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42043. * @param event defines the source event
  42044. * @returns a new SceneLoaderProgressEvent
  42045. */
  42046. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42047. }
  42048. /**
  42049. * Interface used by SceneLoader plugins to define supported file extensions
  42050. */
  42051. export interface ISceneLoaderPluginExtensions {
  42052. /**
  42053. * Defines the list of supported extensions
  42054. */
  42055. [extension: string]: {
  42056. isBinary: boolean;
  42057. };
  42058. }
  42059. /**
  42060. * Interface used by SceneLoader plugin factory
  42061. */
  42062. export interface ISceneLoaderPluginFactory {
  42063. /**
  42064. * Defines the name of the factory
  42065. */
  42066. name: string;
  42067. /**
  42068. * Function called to create a new plugin
  42069. * @return the new plugin
  42070. */
  42071. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42072. /**
  42073. * The callback that returns true if the data can be directly loaded.
  42074. * @param data string containing the file data
  42075. * @returns if the data can be loaded directly
  42076. */
  42077. canDirectLoad?(data: string): boolean;
  42078. }
  42079. /**
  42080. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42081. */
  42082. export interface ISceneLoaderPluginBase {
  42083. /**
  42084. * The friendly name of this plugin.
  42085. */
  42086. name: string;
  42087. /**
  42088. * The file extensions supported by this plugin.
  42089. */
  42090. extensions: string | ISceneLoaderPluginExtensions;
  42091. /**
  42092. * The callback called when loading from a url.
  42093. * @param scene scene loading this url
  42094. * @param url url to load
  42095. * @param onSuccess callback called when the file successfully loads
  42096. * @param onProgress callback called while file is loading (if the server supports this mode)
  42097. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42098. * @param onError callback called when the file fails to load
  42099. * @returns a file request object
  42100. */
  42101. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42102. /**
  42103. * The callback called when loading from a file object.
  42104. * @param scene scene loading this file
  42105. * @param file defines the file to load
  42106. * @param onSuccess defines the callback to call when data is loaded
  42107. * @param onProgress defines the callback to call during loading process
  42108. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42109. * @param onError defines the callback to call when an error occurs
  42110. * @returns a file request object
  42111. */
  42112. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42113. /**
  42114. * The callback that returns true if the data can be directly loaded.
  42115. * @param data string containing the file data
  42116. * @returns if the data can be loaded directly
  42117. */
  42118. canDirectLoad?(data: string): boolean;
  42119. /**
  42120. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42121. * @param scene scene loading this data
  42122. * @param data string containing the data
  42123. * @returns data to pass to the plugin
  42124. */
  42125. directLoad?(scene: Scene, data: string): any;
  42126. /**
  42127. * The callback that allows custom handling of the root url based on the response url.
  42128. * @param rootUrl the original root url
  42129. * @param responseURL the response url if available
  42130. * @returns the new root url
  42131. */
  42132. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42133. }
  42134. /**
  42135. * Interface used to define a SceneLoader plugin
  42136. */
  42137. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42138. /**
  42139. * Import meshes into a scene.
  42140. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42141. * @param scene The scene to import into
  42142. * @param data The data to import
  42143. * @param rootUrl The root url for scene and resources
  42144. * @param meshes The meshes array to import into
  42145. * @param particleSystems The particle systems array to import into
  42146. * @param skeletons The skeletons array to import into
  42147. * @param onError The callback when import fails
  42148. * @returns True if successful or false otherwise
  42149. */
  42150. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42151. /**
  42152. * Load into a scene.
  42153. * @param scene The scene to load into
  42154. * @param data The data to import
  42155. * @param rootUrl The root url for scene and resources
  42156. * @param onError The callback when import fails
  42157. * @returns True if successful or false otherwise
  42158. */
  42159. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42160. /**
  42161. * Load into an asset container.
  42162. * @param scene The scene to load into
  42163. * @param data The data to import
  42164. * @param rootUrl The root url for scene and resources
  42165. * @param onError The callback when import fails
  42166. * @returns The loaded asset container
  42167. */
  42168. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42169. }
  42170. /**
  42171. * Interface used to define an async SceneLoader plugin
  42172. */
  42173. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42174. /**
  42175. * Import meshes into a scene.
  42176. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42177. * @param scene The scene to import into
  42178. * @param data The data to import
  42179. * @param rootUrl The root url for scene and resources
  42180. * @param onProgress The callback when the load progresses
  42181. * @param fileName Defines the name of the file to load
  42182. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42183. */
  42184. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42185. meshes: AbstractMesh[];
  42186. particleSystems: IParticleSystem[];
  42187. skeletons: Skeleton[];
  42188. animationGroups: AnimationGroup[];
  42189. }>;
  42190. /**
  42191. * Load into a scene.
  42192. * @param scene The scene to load into
  42193. * @param data The data to import
  42194. * @param rootUrl The root url for scene and resources
  42195. * @param onProgress The callback when the load progresses
  42196. * @param fileName Defines the name of the file to load
  42197. * @returns Nothing
  42198. */
  42199. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42200. /**
  42201. * Load into an asset container.
  42202. * @param scene The scene to load into
  42203. * @param data The data to import
  42204. * @param rootUrl The root url for scene and resources
  42205. * @param onProgress The callback when the load progresses
  42206. * @param fileName Defines the name of the file to load
  42207. * @returns The loaded asset container
  42208. */
  42209. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42210. }
  42211. /**
  42212. * Class used to load scene from various file formats using registered plugins
  42213. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42214. */
  42215. export class SceneLoader {
  42216. /**
  42217. * No logging while loading
  42218. */
  42219. static readonly NO_LOGGING: number;
  42220. /**
  42221. * Minimal logging while loading
  42222. */
  42223. static readonly MINIMAL_LOGGING: number;
  42224. /**
  42225. * Summary logging while loading
  42226. */
  42227. static readonly SUMMARY_LOGGING: number;
  42228. /**
  42229. * Detailled logging while loading
  42230. */
  42231. static readonly DETAILED_LOGGING: number;
  42232. /**
  42233. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42234. */
  42235. static ForceFullSceneLoadingForIncremental: boolean;
  42236. /**
  42237. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42238. */
  42239. static ShowLoadingScreen: boolean;
  42240. /**
  42241. * Defines the current logging level (while loading the scene)
  42242. * @ignorenaming
  42243. */
  42244. static loggingLevel: number;
  42245. /**
  42246. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42247. */
  42248. static CleanBoneMatrixWeights: boolean;
  42249. /**
  42250. * Event raised when a plugin is used to load a scene
  42251. */
  42252. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42253. private static _registeredPlugins;
  42254. private static _getDefaultPlugin;
  42255. private static _getPluginForExtension;
  42256. private static _getPluginForDirectLoad;
  42257. private static _getPluginForFilename;
  42258. private static _getDirectLoad;
  42259. private static _loadData;
  42260. private static _getFileInfo;
  42261. /**
  42262. * Gets a plugin that can load the given extension
  42263. * @param extension defines the extension to load
  42264. * @returns a plugin or null if none works
  42265. */
  42266. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42267. /**
  42268. * Gets a boolean indicating that the given extension can be loaded
  42269. * @param extension defines the extension to load
  42270. * @returns true if the extension is supported
  42271. */
  42272. static IsPluginForExtensionAvailable(extension: string): boolean;
  42273. /**
  42274. * Adds a new plugin to the list of registered plugins
  42275. * @param plugin defines the plugin to add
  42276. */
  42277. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42278. /**
  42279. * Import meshes into a scene
  42280. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42281. * @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)
  42282. * @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)
  42283. * @param scene the instance of BABYLON.Scene to append to
  42284. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42285. * @param onProgress a callback with a progress event for each file being loaded
  42286. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42287. * @param pluginExtension the extension used to determine the plugin
  42288. * @returns The loaded plugin
  42289. */
  42290. 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>;
  42291. /**
  42292. * Import meshes into a scene
  42293. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42294. * @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)
  42295. * @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)
  42296. * @param scene the instance of BABYLON.Scene to append to
  42297. * @param onProgress a callback with a progress event for each file being loaded
  42298. * @param pluginExtension the extension used to determine the plugin
  42299. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42300. */
  42301. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42302. meshes: AbstractMesh[];
  42303. particleSystems: IParticleSystem[];
  42304. skeletons: Skeleton[];
  42305. animationGroups: AnimationGroup[];
  42306. }>;
  42307. /**
  42308. * Load a scene
  42309. * @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)
  42310. * @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)
  42311. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42312. * @param onSuccess a callback with the scene when import succeeds
  42313. * @param onProgress a callback with a progress event for each file being loaded
  42314. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42315. * @param pluginExtension the extension used to determine the plugin
  42316. * @returns The loaded plugin
  42317. */
  42318. 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>;
  42319. /**
  42320. * Load a scene
  42321. * @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)
  42322. * @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)
  42323. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42324. * @param onProgress a callback with a progress event for each file being loaded
  42325. * @param pluginExtension the extension used to determine the plugin
  42326. * @returns The loaded scene
  42327. */
  42328. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42329. /**
  42330. * Append a scene
  42331. * @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)
  42332. * @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)
  42333. * @param scene is the instance of BABYLON.Scene to append to
  42334. * @param onSuccess a callback with the scene when import succeeds
  42335. * @param onProgress a callback with a progress event for each file being loaded
  42336. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42337. * @param pluginExtension the extension used to determine the plugin
  42338. * @returns The loaded plugin
  42339. */
  42340. 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>;
  42341. /**
  42342. * Append a scene
  42343. * @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)
  42344. * @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)
  42345. * @param scene is the instance of BABYLON.Scene to append to
  42346. * @param onProgress a callback with a progress event for each file being loaded
  42347. * @param pluginExtension the extension used to determine the plugin
  42348. * @returns The given scene
  42349. */
  42350. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42351. /**
  42352. * Load a scene into an asset container
  42353. * @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)
  42354. * @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)
  42355. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42356. * @param onSuccess a callback with the scene when import succeeds
  42357. * @param onProgress a callback with a progress event for each file being loaded
  42358. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42359. * @param pluginExtension the extension used to determine the plugin
  42360. * @returns The loaded plugin
  42361. */
  42362. 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>;
  42363. /**
  42364. * Load a scene into an asset container
  42365. * @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)
  42366. * @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)
  42367. * @param scene is the instance of Scene to append to
  42368. * @param onProgress a callback with a progress event for each file being loaded
  42369. * @param pluginExtension the extension used to determine the plugin
  42370. * @returns The loaded asset container
  42371. */
  42372. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42373. }
  42374. }
  42375. declare module BABYLON {
  42376. /**
  42377. * Generic Controller
  42378. */
  42379. export class GenericController extends WebVRController {
  42380. /**
  42381. * Base Url for the controller model.
  42382. */
  42383. static readonly MODEL_BASE_URL: string;
  42384. /**
  42385. * File name for the controller model.
  42386. */
  42387. static readonly MODEL_FILENAME: string;
  42388. /**
  42389. * Creates a new GenericController from a gamepad
  42390. * @param vrGamepad the gamepad that the controller should be created from
  42391. */
  42392. constructor(vrGamepad: any);
  42393. /**
  42394. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42395. * @param scene scene in which to add meshes
  42396. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42397. */
  42398. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42399. /**
  42400. * Called once for each button that changed state since the last frame
  42401. * @param buttonIdx Which button index changed
  42402. * @param state New state of the button
  42403. * @param changes Which properties on the state changed since last frame
  42404. */
  42405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Defines the WindowsMotionController object that the state of the windows motion controller
  42411. */
  42412. export class WindowsMotionController extends WebVRController {
  42413. /**
  42414. * The base url used to load the left and right controller models
  42415. */
  42416. static MODEL_BASE_URL: string;
  42417. /**
  42418. * The name of the left controller model file
  42419. */
  42420. static MODEL_LEFT_FILENAME: string;
  42421. /**
  42422. * The name of the right controller model file
  42423. */
  42424. static MODEL_RIGHT_FILENAME: string;
  42425. /**
  42426. * The controller name prefix for this controller type
  42427. */
  42428. static readonly GAMEPAD_ID_PREFIX: string;
  42429. /**
  42430. * The controller id pattern for this controller type
  42431. */
  42432. private static readonly GAMEPAD_ID_PATTERN;
  42433. private _loadedMeshInfo;
  42434. private readonly _mapping;
  42435. /**
  42436. * Fired when the trackpad on this controller is clicked
  42437. */
  42438. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42439. /**
  42440. * Fired when the trackpad on this controller is modified
  42441. */
  42442. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42443. /**
  42444. * The current x and y values of this controller's trackpad
  42445. */
  42446. trackpad: StickValues;
  42447. /**
  42448. * Creates a new WindowsMotionController from a gamepad
  42449. * @param vrGamepad the gamepad that the controller should be created from
  42450. */
  42451. constructor(vrGamepad: any);
  42452. /**
  42453. * Fired when the trigger on this controller is modified
  42454. */
  42455. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42456. /**
  42457. * Fired when the menu button on this controller is modified
  42458. */
  42459. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42460. /**
  42461. * Fired when the grip button on this controller is modified
  42462. */
  42463. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42464. /**
  42465. * Fired when the thumbstick button on this controller is modified
  42466. */
  42467. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42468. /**
  42469. * Fired when the touchpad button on this controller is modified
  42470. */
  42471. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42472. /**
  42473. * Fired when the touchpad values on this controller are modified
  42474. */
  42475. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42476. private _updateTrackpad;
  42477. /**
  42478. * Called once per frame by the engine.
  42479. */
  42480. update(): void;
  42481. /**
  42482. * Called once for each button that changed state since the last frame
  42483. * @param buttonIdx Which button index changed
  42484. * @param state New state of the button
  42485. * @param changes Which properties on the state changed since last frame
  42486. */
  42487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42488. /**
  42489. * Moves the buttons on the controller mesh based on their current state
  42490. * @param buttonName the name of the button to move
  42491. * @param buttonValue the value of the button which determines the buttons new position
  42492. */
  42493. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42494. /**
  42495. * Moves the axis on the controller mesh based on its current state
  42496. * @param axis the index of the axis
  42497. * @param axisValue the value of the axis which determines the meshes new position
  42498. * @hidden
  42499. */
  42500. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42501. /**
  42502. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42503. * @param scene scene in which to add meshes
  42504. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42505. */
  42506. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42507. /**
  42508. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42509. * can be transformed by button presses and axes values, based on this._mapping.
  42510. *
  42511. * @param scene scene in which the meshes exist
  42512. * @param meshes list of meshes that make up the controller model to process
  42513. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42514. */
  42515. private processModel;
  42516. private createMeshInfo;
  42517. /**
  42518. * Gets the ray of the controller in the direction the controller is pointing
  42519. * @param length the length the resulting ray should be
  42520. * @returns a ray in the direction the controller is pointing
  42521. */
  42522. getForwardRay(length?: number): Ray;
  42523. /**
  42524. * Disposes of the controller
  42525. */
  42526. dispose(): void;
  42527. }
  42528. }
  42529. declare module BABYLON {
  42530. /**
  42531. * Oculus Touch Controller
  42532. */
  42533. export class OculusTouchController extends WebVRController {
  42534. /**
  42535. * Base Url for the controller model.
  42536. */
  42537. static MODEL_BASE_URL: string;
  42538. /**
  42539. * File name for the left controller model.
  42540. */
  42541. static MODEL_LEFT_FILENAME: string;
  42542. /**
  42543. * File name for the right controller model.
  42544. */
  42545. static MODEL_RIGHT_FILENAME: string;
  42546. /**
  42547. * Base Url for the Quest controller model.
  42548. */
  42549. static QUEST_MODEL_BASE_URL: string;
  42550. /**
  42551. * @hidden
  42552. * If the controllers are running on a device that needs the updated Quest controller models
  42553. */
  42554. static _IsQuest: boolean;
  42555. /**
  42556. * Fired when the secondary trigger on this controller is modified
  42557. */
  42558. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42559. /**
  42560. * Fired when the thumb rest on this controller is modified
  42561. */
  42562. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42563. /**
  42564. * Creates a new OculusTouchController from a gamepad
  42565. * @param vrGamepad the gamepad that the controller should be created from
  42566. */
  42567. constructor(vrGamepad: any);
  42568. /**
  42569. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42570. * @param scene scene in which to add meshes
  42571. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42572. */
  42573. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42574. /**
  42575. * Fired when the A button on this controller is modified
  42576. */
  42577. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42578. /**
  42579. * Fired when the B button on this controller is modified
  42580. */
  42581. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42582. /**
  42583. * Fired when the X button on this controller is modified
  42584. */
  42585. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42586. /**
  42587. * Fired when the Y button on this controller is modified
  42588. */
  42589. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42590. /**
  42591. * Called once for each button that changed state since the last frame
  42592. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42593. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42594. * 2) secondary trigger (same)
  42595. * 3) A (right) X (left), touch, pressed = value
  42596. * 4) B / Y
  42597. * 5) thumb rest
  42598. * @param buttonIdx Which button index changed
  42599. * @param state New state of the button
  42600. * @param changes Which properties on the state changed since last frame
  42601. */
  42602. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42603. }
  42604. }
  42605. declare module BABYLON {
  42606. /**
  42607. * Vive Controller
  42608. */
  42609. export class ViveController extends WebVRController {
  42610. /**
  42611. * Base Url for the controller model.
  42612. */
  42613. static MODEL_BASE_URL: string;
  42614. /**
  42615. * File name for the controller model.
  42616. */
  42617. static MODEL_FILENAME: string;
  42618. /**
  42619. * Creates a new ViveController from a gamepad
  42620. * @param vrGamepad the gamepad that the controller should be created from
  42621. */
  42622. constructor(vrGamepad: any);
  42623. /**
  42624. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42625. * @param scene scene in which to add meshes
  42626. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42627. */
  42628. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42629. /**
  42630. * Fired when the left button on this controller is modified
  42631. */
  42632. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42633. /**
  42634. * Fired when the right button on this controller is modified
  42635. */
  42636. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42637. /**
  42638. * Fired when the menu button on this controller is modified
  42639. */
  42640. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42641. /**
  42642. * Called once for each button that changed state since the last frame
  42643. * Vive mapping:
  42644. * 0: touchpad
  42645. * 1: trigger
  42646. * 2: left AND right buttons
  42647. * 3: menu button
  42648. * @param buttonIdx Which button index changed
  42649. * @param state New state of the button
  42650. * @param changes Which properties on the state changed since last frame
  42651. */
  42652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42653. }
  42654. }
  42655. declare module BABYLON {
  42656. /**
  42657. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42658. */
  42659. export class WebXRControllerModelLoader {
  42660. /**
  42661. * Creates the WebXRControllerModelLoader
  42662. * @param input xr input that creates the controllers
  42663. */
  42664. constructor(input: WebXRInput);
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * Contains an array of blocks representing the octree
  42670. */
  42671. export interface IOctreeContainer<T> {
  42672. /**
  42673. * Blocks within the octree
  42674. */
  42675. blocks: Array<OctreeBlock<T>>;
  42676. }
  42677. /**
  42678. * Class used to store a cell in an octree
  42679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42680. */
  42681. export class OctreeBlock<T> {
  42682. /**
  42683. * Gets the content of the current block
  42684. */
  42685. entries: T[];
  42686. /**
  42687. * Gets the list of block children
  42688. */
  42689. blocks: Array<OctreeBlock<T>>;
  42690. private _depth;
  42691. private _maxDepth;
  42692. private _capacity;
  42693. private _minPoint;
  42694. private _maxPoint;
  42695. private _boundingVectors;
  42696. private _creationFunc;
  42697. /**
  42698. * Creates a new block
  42699. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42700. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42701. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42702. * @param depth defines the current depth of this block in the octree
  42703. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42704. * @param creationFunc defines a callback to call when an element is added to the block
  42705. */
  42706. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42707. /**
  42708. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42709. */
  42710. readonly capacity: number;
  42711. /**
  42712. * Gets the minimum vector (in world space) of the block's bounding box
  42713. */
  42714. readonly minPoint: Vector3;
  42715. /**
  42716. * Gets the maximum vector (in world space) of the block's bounding box
  42717. */
  42718. readonly maxPoint: Vector3;
  42719. /**
  42720. * Add a new element to this block
  42721. * @param entry defines the element to add
  42722. */
  42723. addEntry(entry: T): void;
  42724. /**
  42725. * Remove an element from this block
  42726. * @param entry defines the element to remove
  42727. */
  42728. removeEntry(entry: T): void;
  42729. /**
  42730. * Add an array of elements to this block
  42731. * @param entries defines the array of elements to add
  42732. */
  42733. addEntries(entries: T[]): void;
  42734. /**
  42735. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42736. * @param frustumPlanes defines the frustum planes to test
  42737. * @param selection defines the array to store current content if selection is positive
  42738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42739. */
  42740. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42741. /**
  42742. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42743. * @param sphereCenter defines the bounding sphere center
  42744. * @param sphereRadius defines the bounding sphere radius
  42745. * @param selection defines the array to store current content if selection is positive
  42746. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42747. */
  42748. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42749. /**
  42750. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42751. * @param ray defines the ray to test with
  42752. * @param selection defines the array to store current content if selection is positive
  42753. */
  42754. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42755. /**
  42756. * Subdivide the content into child blocks (this block will then be empty)
  42757. */
  42758. createInnerBlocks(): void;
  42759. /**
  42760. * @hidden
  42761. */
  42762. 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;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42769. */
  42770. export class Octree<T> {
  42771. /** 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.) */
  42772. maxDepth: number;
  42773. /**
  42774. * Blocks within the octree containing objects
  42775. */
  42776. blocks: Array<OctreeBlock<T>>;
  42777. /**
  42778. * Content stored in the octree
  42779. */
  42780. dynamicContent: T[];
  42781. private _maxBlockCapacity;
  42782. private _selectionContent;
  42783. private _creationFunc;
  42784. /**
  42785. * Creates a octree
  42786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42787. * @param creationFunc function to be used to instatiate the octree
  42788. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42789. * @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.)
  42790. */
  42791. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42792. /** 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.) */
  42793. maxDepth?: number);
  42794. /**
  42795. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42796. * @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);
  42797. * @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);
  42798. * @param entries meshes to be added to the octree blocks
  42799. */
  42800. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42801. /**
  42802. * Adds a mesh to the octree
  42803. * @param entry Mesh to add to the octree
  42804. */
  42805. addMesh(entry: T): void;
  42806. /**
  42807. * Remove an element from the octree
  42808. * @param entry defines the element to remove
  42809. */
  42810. removeMesh(entry: T): void;
  42811. /**
  42812. * Selects an array of meshes within the frustum
  42813. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42814. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42815. * @returns array of meshes within the frustum
  42816. */
  42817. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42818. /**
  42819. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42820. * @param sphereCenter defines the bounding sphere center
  42821. * @param sphereRadius defines the bounding sphere radius
  42822. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42823. * @returns an array of objects that intersect the sphere
  42824. */
  42825. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42826. /**
  42827. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42828. * @param ray defines the ray to test with
  42829. * @returns array of intersected objects
  42830. */
  42831. intersectsRay(ray: Ray): SmartArray<T>;
  42832. /**
  42833. * Adds a mesh into the octree block if it intersects the block
  42834. */
  42835. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42836. /**
  42837. * Adds a submesh into the octree block if it intersects the block
  42838. */
  42839. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42840. }
  42841. }
  42842. declare module BABYLON {
  42843. interface Scene {
  42844. /**
  42845. * @hidden
  42846. * Backing Filed
  42847. */
  42848. _selectionOctree: Octree<AbstractMesh>;
  42849. /**
  42850. * Gets the octree used to boost mesh selection (picking)
  42851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42852. */
  42853. selectionOctree: Octree<AbstractMesh>;
  42854. /**
  42855. * Creates or updates the octree used to boost selection (picking)
  42856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42857. * @param maxCapacity defines the maximum capacity per leaf
  42858. * @param maxDepth defines the maximum depth of the octree
  42859. * @returns an octree of AbstractMesh
  42860. */
  42861. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42862. }
  42863. interface AbstractMesh {
  42864. /**
  42865. * @hidden
  42866. * Backing Field
  42867. */
  42868. _submeshesOctree: Octree<SubMesh>;
  42869. /**
  42870. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42871. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42872. * @param maxCapacity defines the maximum size of each block (64 by default)
  42873. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42874. * @returns the new octree
  42875. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42877. */
  42878. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42879. }
  42880. /**
  42881. * Defines the octree scene component responsible to manage any octrees
  42882. * in a given scene.
  42883. */
  42884. export class OctreeSceneComponent {
  42885. /**
  42886. * The component name help to identify the component in the list of scene components.
  42887. */
  42888. readonly name: string;
  42889. /**
  42890. * The scene the component belongs to.
  42891. */
  42892. scene: Scene;
  42893. /**
  42894. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42895. */
  42896. readonly checksIsEnabled: boolean;
  42897. /**
  42898. * Creates a new instance of the component for the given scene
  42899. * @param scene Defines the scene to register the component in
  42900. */
  42901. constructor(scene: Scene);
  42902. /**
  42903. * Registers the component in a given scene
  42904. */
  42905. register(): void;
  42906. /**
  42907. * Return the list of active meshes
  42908. * @returns the list of active meshes
  42909. */
  42910. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42911. /**
  42912. * Return the list of active sub meshes
  42913. * @param mesh The mesh to get the candidates sub meshes from
  42914. * @returns the list of active sub meshes
  42915. */
  42916. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42917. private _tempRay;
  42918. /**
  42919. * Return the list of sub meshes intersecting with a given local ray
  42920. * @param mesh defines the mesh to find the submesh for
  42921. * @param localRay defines the ray in local space
  42922. * @returns the list of intersecting sub meshes
  42923. */
  42924. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42925. /**
  42926. * Return the list of sub meshes colliding with a collider
  42927. * @param mesh defines the mesh to find the submesh for
  42928. * @param collider defines the collider to evaluate the collision against
  42929. * @returns the list of colliding sub meshes
  42930. */
  42931. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42932. /**
  42933. * Rebuilds the elements related to this component in case of
  42934. * context lost for instance.
  42935. */
  42936. rebuild(): void;
  42937. /**
  42938. * Disposes the component and the associated ressources.
  42939. */
  42940. dispose(): void;
  42941. }
  42942. }
  42943. declare module BABYLON {
  42944. /**
  42945. * Renders a layer on top of an existing scene
  42946. */
  42947. export class UtilityLayerRenderer implements IDisposable {
  42948. /** the original scene that will be rendered on top of */
  42949. originalScene: Scene;
  42950. private _pointerCaptures;
  42951. private _lastPointerEvents;
  42952. private static _DefaultUtilityLayer;
  42953. private static _DefaultKeepDepthUtilityLayer;
  42954. private _sharedGizmoLight;
  42955. private _renderCamera;
  42956. /**
  42957. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42958. * @returns the camera that is used when rendering the utility layer
  42959. */
  42960. getRenderCamera(): Nullable<Camera>;
  42961. /**
  42962. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42963. * @param cam the camera that should be used when rendering the utility layer
  42964. */
  42965. setRenderCamera(cam: Nullable<Camera>): void;
  42966. /**
  42967. * @hidden
  42968. * Light which used by gizmos to get light shading
  42969. */
  42970. _getSharedGizmoLight(): HemisphericLight;
  42971. /**
  42972. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42973. */
  42974. pickUtilitySceneFirst: boolean;
  42975. /**
  42976. * 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)
  42977. */
  42978. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42979. /**
  42980. * 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)
  42981. */
  42982. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42983. /**
  42984. * The scene that is rendered on top of the original scene
  42985. */
  42986. utilityLayerScene: Scene;
  42987. /**
  42988. * If the utility layer should automatically be rendered on top of existing scene
  42989. */
  42990. shouldRender: boolean;
  42991. /**
  42992. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42993. */
  42994. onlyCheckPointerDownEvents: boolean;
  42995. /**
  42996. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42997. */
  42998. processAllEvents: boolean;
  42999. /**
  43000. * Observable raised when the pointer move from the utility layer scene to the main scene
  43001. */
  43002. onPointerOutObservable: Observable<number>;
  43003. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43004. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43005. private _afterRenderObserver;
  43006. private _sceneDisposeObserver;
  43007. private _originalPointerObserver;
  43008. /**
  43009. * Instantiates a UtilityLayerRenderer
  43010. * @param originalScene the original scene that will be rendered on top of
  43011. * @param handleEvents boolean indicating if the utility layer should handle events
  43012. */
  43013. constructor(
  43014. /** the original scene that will be rendered on top of */
  43015. originalScene: Scene, handleEvents?: boolean);
  43016. private _notifyObservers;
  43017. /**
  43018. * Renders the utility layers scene on top of the original scene
  43019. */
  43020. render(): void;
  43021. /**
  43022. * Disposes of the renderer
  43023. */
  43024. dispose(): void;
  43025. private _updateCamera;
  43026. }
  43027. }
  43028. declare module BABYLON {
  43029. /**
  43030. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43031. */
  43032. export class Gizmo implements IDisposable {
  43033. /** The utility layer the gizmo will be added to */
  43034. gizmoLayer: UtilityLayerRenderer;
  43035. /**
  43036. * The root mesh of the gizmo
  43037. */
  43038. _rootMesh: Mesh;
  43039. private _attachedMesh;
  43040. /**
  43041. * Ratio for the scale of the gizmo (Default: 1)
  43042. */
  43043. scaleRatio: number;
  43044. /**
  43045. * If a custom mesh has been set (Default: false)
  43046. */
  43047. protected _customMeshSet: boolean;
  43048. /**
  43049. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43050. * * When set, interactions will be enabled
  43051. */
  43052. attachedMesh: Nullable<AbstractMesh>;
  43053. /**
  43054. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43055. * @param mesh The mesh to replace the default mesh of the gizmo
  43056. */
  43057. setCustomMesh(mesh: Mesh): void;
  43058. /**
  43059. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43060. */
  43061. updateGizmoRotationToMatchAttachedMesh: boolean;
  43062. /**
  43063. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43064. */
  43065. updateGizmoPositionToMatchAttachedMesh: boolean;
  43066. /**
  43067. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43068. */
  43069. updateScale: boolean;
  43070. protected _interactionsEnabled: boolean;
  43071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43072. private _beforeRenderObserver;
  43073. private _tempVector;
  43074. /**
  43075. * Creates a gizmo
  43076. * @param gizmoLayer The utility layer the gizmo will be added to
  43077. */
  43078. constructor(
  43079. /** The utility layer the gizmo will be added to */
  43080. gizmoLayer?: UtilityLayerRenderer);
  43081. /**
  43082. * Updates the gizmo to match the attached mesh's position/rotation
  43083. */
  43084. protected _update(): void;
  43085. /**
  43086. * Disposes of the gizmo
  43087. */
  43088. dispose(): void;
  43089. }
  43090. }
  43091. declare module BABYLON {
  43092. /**
  43093. * Single plane drag gizmo
  43094. */
  43095. export class PlaneDragGizmo extends Gizmo {
  43096. /**
  43097. * Drag behavior responsible for the gizmos dragging interactions
  43098. */
  43099. dragBehavior: PointerDragBehavior;
  43100. private _pointerObserver;
  43101. /**
  43102. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43103. */
  43104. snapDistance: number;
  43105. /**
  43106. * Event that fires each time the gizmo snaps to a new location.
  43107. * * snapDistance is the the change in distance
  43108. */
  43109. onSnapObservable: Observable<{
  43110. snapDistance: number;
  43111. }>;
  43112. private _plane;
  43113. private _coloredMaterial;
  43114. private _hoverMaterial;
  43115. private _isEnabled;
  43116. private _parent;
  43117. /** @hidden */
  43118. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43119. /** @hidden */
  43120. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43121. /**
  43122. * Creates a PlaneDragGizmo
  43123. * @param gizmoLayer The utility layer the gizmo will be added to
  43124. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43125. * @param color The color of the gizmo
  43126. */
  43127. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43129. /**
  43130. * If the gizmo is enabled
  43131. */
  43132. isEnabled: boolean;
  43133. /**
  43134. * Disposes of the gizmo
  43135. */
  43136. dispose(): void;
  43137. }
  43138. }
  43139. declare module BABYLON {
  43140. /**
  43141. * Gizmo that enables dragging a mesh along 3 axis
  43142. */
  43143. export class PositionGizmo extends Gizmo {
  43144. /**
  43145. * Internal gizmo used for interactions on the x axis
  43146. */
  43147. xGizmo: AxisDragGizmo;
  43148. /**
  43149. * Internal gizmo used for interactions on the y axis
  43150. */
  43151. yGizmo: AxisDragGizmo;
  43152. /**
  43153. * Internal gizmo used for interactions on the z axis
  43154. */
  43155. zGizmo: AxisDragGizmo;
  43156. /**
  43157. * Internal gizmo used for interactions on the yz plane
  43158. */
  43159. xPlaneGizmo: PlaneDragGizmo;
  43160. /**
  43161. * Internal gizmo used for interactions on the xz plane
  43162. */
  43163. yPlaneGizmo: PlaneDragGizmo;
  43164. /**
  43165. * Internal gizmo used for interactions on the xy plane
  43166. */
  43167. zPlaneGizmo: PlaneDragGizmo;
  43168. /**
  43169. * private variables
  43170. */
  43171. private _meshAttached;
  43172. private _updateGizmoRotationToMatchAttachedMesh;
  43173. private _snapDistance;
  43174. private _scaleRatio;
  43175. /** Fires an event when any of it's sub gizmos are dragged */
  43176. onDragStartObservable: Observable<unknown>;
  43177. /** Fires an event when any of it's sub gizmos are released from dragging */
  43178. onDragEndObservable: Observable<unknown>;
  43179. /**
  43180. * If set to true, planar drag is enabled
  43181. */
  43182. private _planarGizmoEnabled;
  43183. attachedMesh: Nullable<AbstractMesh>;
  43184. /**
  43185. * Creates a PositionGizmo
  43186. * @param gizmoLayer The utility layer the gizmo will be added to
  43187. */
  43188. constructor(gizmoLayer?: UtilityLayerRenderer);
  43189. /**
  43190. * If the planar drag gizmo is enabled
  43191. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43192. */
  43193. planarGizmoEnabled: boolean;
  43194. updateGizmoRotationToMatchAttachedMesh: boolean;
  43195. /**
  43196. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43197. */
  43198. snapDistance: number;
  43199. /**
  43200. * Ratio for the scale of the gizmo (Default: 1)
  43201. */
  43202. scaleRatio: number;
  43203. /**
  43204. * Disposes of the gizmo
  43205. */
  43206. dispose(): void;
  43207. /**
  43208. * CustomMeshes are not supported by this gizmo
  43209. * @param mesh The mesh to replace the default mesh of the gizmo
  43210. */
  43211. setCustomMesh(mesh: Mesh): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Single axis drag gizmo
  43217. */
  43218. export class AxisDragGizmo extends Gizmo {
  43219. /**
  43220. * Drag behavior responsible for the gizmos dragging interactions
  43221. */
  43222. dragBehavior: PointerDragBehavior;
  43223. private _pointerObserver;
  43224. /**
  43225. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43226. */
  43227. snapDistance: number;
  43228. /**
  43229. * Event that fires each time the gizmo snaps to a new location.
  43230. * * snapDistance is the the change in distance
  43231. */
  43232. onSnapObservable: Observable<{
  43233. snapDistance: number;
  43234. }>;
  43235. private _isEnabled;
  43236. private _parent;
  43237. private _arrow;
  43238. private _coloredMaterial;
  43239. private _hoverMaterial;
  43240. /** @hidden */
  43241. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43242. /** @hidden */
  43243. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43244. /**
  43245. * Creates an AxisDragGizmo
  43246. * @param gizmoLayer The utility layer the gizmo will be added to
  43247. * @param dragAxis The axis which the gizmo will be able to drag on
  43248. * @param color The color of the gizmo
  43249. */
  43250. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43251. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43252. /**
  43253. * If the gizmo is enabled
  43254. */
  43255. isEnabled: boolean;
  43256. /**
  43257. * Disposes of the gizmo
  43258. */
  43259. dispose(): void;
  43260. }
  43261. }
  43262. declare module BABYLON.Debug {
  43263. /**
  43264. * The Axes viewer will show 3 axes in a specific point in space
  43265. */
  43266. export class AxesViewer {
  43267. private _xAxis;
  43268. private _yAxis;
  43269. private _zAxis;
  43270. private _scaleLinesFactor;
  43271. private _instanced;
  43272. /**
  43273. * Gets the hosting scene
  43274. */
  43275. scene: Scene;
  43276. /**
  43277. * Gets or sets a number used to scale line length
  43278. */
  43279. scaleLines: number;
  43280. /** Gets the node hierarchy used to render x-axis */
  43281. readonly xAxis: TransformNode;
  43282. /** Gets the node hierarchy used to render y-axis */
  43283. readonly yAxis: TransformNode;
  43284. /** Gets the node hierarchy used to render z-axis */
  43285. readonly zAxis: TransformNode;
  43286. /**
  43287. * Creates a new AxesViewer
  43288. * @param scene defines the hosting scene
  43289. * @param scaleLines defines a number used to scale line length (1 by default)
  43290. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43291. * @param xAxis defines the node hierarchy used to render the x-axis
  43292. * @param yAxis defines the node hierarchy used to render the y-axis
  43293. * @param zAxis defines the node hierarchy used to render the z-axis
  43294. */
  43295. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43296. /**
  43297. * Force the viewer to update
  43298. * @param position defines the position of the viewer
  43299. * @param xaxis defines the x axis of the viewer
  43300. * @param yaxis defines the y axis of the viewer
  43301. * @param zaxis defines the z axis of the viewer
  43302. */
  43303. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43304. /**
  43305. * Creates an instance of this axes viewer.
  43306. * @returns a new axes viewer with instanced meshes
  43307. */
  43308. createInstance(): AxesViewer;
  43309. /** Releases resources */
  43310. dispose(): void;
  43311. private static _SetRenderingGroupId;
  43312. }
  43313. }
  43314. declare module BABYLON.Debug {
  43315. /**
  43316. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43317. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43318. */
  43319. export class BoneAxesViewer extends AxesViewer {
  43320. /**
  43321. * Gets or sets the target mesh where to display the axes viewer
  43322. */
  43323. mesh: Nullable<Mesh>;
  43324. /**
  43325. * Gets or sets the target bone where to display the axes viewer
  43326. */
  43327. bone: Nullable<Bone>;
  43328. /** Gets current position */
  43329. pos: Vector3;
  43330. /** Gets direction of X axis */
  43331. xaxis: Vector3;
  43332. /** Gets direction of Y axis */
  43333. yaxis: Vector3;
  43334. /** Gets direction of Z axis */
  43335. zaxis: Vector3;
  43336. /**
  43337. * Creates a new BoneAxesViewer
  43338. * @param scene defines the hosting scene
  43339. * @param bone defines the target bone
  43340. * @param mesh defines the target mesh
  43341. * @param scaleLines defines a scaling factor for line length (1 by default)
  43342. */
  43343. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43344. /**
  43345. * Force the viewer to update
  43346. */
  43347. update(): void;
  43348. /** Releases resources */
  43349. dispose(): void;
  43350. }
  43351. }
  43352. declare module BABYLON {
  43353. /**
  43354. * Interface used to define scene explorer extensibility option
  43355. */
  43356. export interface IExplorerExtensibilityOption {
  43357. /**
  43358. * Define the option label
  43359. */
  43360. label: string;
  43361. /**
  43362. * Defines the action to execute on click
  43363. */
  43364. action: (entity: any) => void;
  43365. }
  43366. /**
  43367. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43368. */
  43369. export interface IExplorerExtensibilityGroup {
  43370. /**
  43371. * Defines a predicate to test if a given type mut be extended
  43372. */
  43373. predicate: (entity: any) => boolean;
  43374. /**
  43375. * Gets the list of options added to a type
  43376. */
  43377. entries: IExplorerExtensibilityOption[];
  43378. }
  43379. /**
  43380. * Interface used to define the options to use to create the Inspector
  43381. */
  43382. export interface IInspectorOptions {
  43383. /**
  43384. * Display in overlay mode (default: false)
  43385. */
  43386. overlay?: boolean;
  43387. /**
  43388. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43389. */
  43390. globalRoot?: HTMLElement;
  43391. /**
  43392. * Display the Scene explorer
  43393. */
  43394. showExplorer?: boolean;
  43395. /**
  43396. * Display the property inspector
  43397. */
  43398. showInspector?: boolean;
  43399. /**
  43400. * Display in embed mode (both panes on the right)
  43401. */
  43402. embedMode?: boolean;
  43403. /**
  43404. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43405. */
  43406. handleResize?: boolean;
  43407. /**
  43408. * Allow the panes to popup (default: true)
  43409. */
  43410. enablePopup?: boolean;
  43411. /**
  43412. * Allow the panes to be closed by users (default: true)
  43413. */
  43414. enableClose?: boolean;
  43415. /**
  43416. * Optional list of extensibility entries
  43417. */
  43418. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43419. /**
  43420. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43421. */
  43422. inspectorURL?: string;
  43423. }
  43424. interface Scene {
  43425. /**
  43426. * @hidden
  43427. * Backing field
  43428. */
  43429. _debugLayer: DebugLayer;
  43430. /**
  43431. * Gets the debug layer (aka Inspector) associated with the scene
  43432. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43433. */
  43434. debugLayer: DebugLayer;
  43435. }
  43436. /**
  43437. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43438. * what is happening in your scene
  43439. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43440. */
  43441. export class DebugLayer {
  43442. /**
  43443. * Define the url to get the inspector script from.
  43444. * By default it uses the babylonjs CDN.
  43445. * @ignoreNaming
  43446. */
  43447. static InspectorURL: string;
  43448. private _scene;
  43449. private BJSINSPECTOR;
  43450. private _onPropertyChangedObservable?;
  43451. /**
  43452. * Observable triggered when a property is changed through the inspector.
  43453. */
  43454. readonly onPropertyChangedObservable: any;
  43455. /**
  43456. * Instantiates a new debug layer.
  43457. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43458. * what is happening in your scene
  43459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43460. * @param scene Defines the scene to inspect
  43461. */
  43462. constructor(scene: Scene);
  43463. /** Creates the inspector window. */
  43464. private _createInspector;
  43465. /**
  43466. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43467. * @param entity defines the entity to select
  43468. * @param lineContainerTitle defines the specific block to highlight
  43469. */
  43470. select(entity: any, lineContainerTitle?: string): void;
  43471. /** Get the inspector from bundle or global */
  43472. private _getGlobalInspector;
  43473. /**
  43474. * Get if the inspector is visible or not.
  43475. * @returns true if visible otherwise, false
  43476. */
  43477. isVisible(): boolean;
  43478. /**
  43479. * Hide the inspector and close its window.
  43480. */
  43481. hide(): void;
  43482. /**
  43483. * Launch the debugLayer.
  43484. * @param config Define the configuration of the inspector
  43485. * @return a promise fulfilled when the debug layer is visible
  43486. */
  43487. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43488. }
  43489. }
  43490. declare module BABYLON {
  43491. /**
  43492. * Class containing static functions to help procedurally build meshes
  43493. */
  43494. export class BoxBuilder {
  43495. /**
  43496. * Creates a box mesh
  43497. * * The parameter `size` sets the size (float) of each box side (default 1)
  43498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43499. * * 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)
  43500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43502. * * 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
  43503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43505. * @param name defines the name of the mesh
  43506. * @param options defines the options used to create the mesh
  43507. * @param scene defines the hosting scene
  43508. * @returns the box mesh
  43509. */
  43510. static CreateBox(name: string, options: {
  43511. size?: number;
  43512. width?: number;
  43513. height?: number;
  43514. depth?: number;
  43515. faceUV?: Vector4[];
  43516. faceColors?: Color4[];
  43517. sideOrientation?: number;
  43518. frontUVs?: Vector4;
  43519. backUVs?: Vector4;
  43520. wrap?: boolean;
  43521. topBaseAt?: number;
  43522. bottomBaseAt?: number;
  43523. updatable?: boolean;
  43524. }, scene?: Nullable<Scene>): Mesh;
  43525. }
  43526. }
  43527. declare module BABYLON {
  43528. /**
  43529. * Class containing static functions to help procedurally build meshes
  43530. */
  43531. export class SphereBuilder {
  43532. /**
  43533. * Creates a sphere mesh
  43534. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43535. * * 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`)
  43536. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43537. * * 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
  43538. * * 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)
  43539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43540. * * 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
  43541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43542. * @param name defines the name of the mesh
  43543. * @param options defines the options used to create the mesh
  43544. * @param scene defines the hosting scene
  43545. * @returns the sphere mesh
  43546. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43547. */
  43548. static CreateSphere(name: string, options: {
  43549. segments?: number;
  43550. diameter?: number;
  43551. diameterX?: number;
  43552. diameterY?: number;
  43553. diameterZ?: number;
  43554. arc?: number;
  43555. slice?: number;
  43556. sideOrientation?: number;
  43557. frontUVs?: Vector4;
  43558. backUVs?: Vector4;
  43559. updatable?: boolean;
  43560. }, scene?: Nullable<Scene>): Mesh;
  43561. }
  43562. }
  43563. declare module BABYLON.Debug {
  43564. /**
  43565. * Used to show the physics impostor around the specific mesh
  43566. */
  43567. export class PhysicsViewer {
  43568. /** @hidden */
  43569. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43570. /** @hidden */
  43571. protected _meshes: Array<Nullable<AbstractMesh>>;
  43572. /** @hidden */
  43573. protected _scene: Nullable<Scene>;
  43574. /** @hidden */
  43575. protected _numMeshes: number;
  43576. /** @hidden */
  43577. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43578. private _renderFunction;
  43579. private _utilityLayer;
  43580. private _debugBoxMesh;
  43581. private _debugSphereMesh;
  43582. private _debugCylinderMesh;
  43583. private _debugMaterial;
  43584. private _debugMeshMeshes;
  43585. /**
  43586. * Creates a new PhysicsViewer
  43587. * @param scene defines the hosting scene
  43588. */
  43589. constructor(scene: Scene);
  43590. /** @hidden */
  43591. protected _updateDebugMeshes(): void;
  43592. /**
  43593. * Renders a specified physic impostor
  43594. * @param impostor defines the impostor to render
  43595. * @param targetMesh defines the mesh represented by the impostor
  43596. * @returns the new debug mesh used to render the impostor
  43597. */
  43598. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43599. /**
  43600. * Hides a specified physic impostor
  43601. * @param impostor defines the impostor to hide
  43602. */
  43603. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43604. private _getDebugMaterial;
  43605. private _getDebugBoxMesh;
  43606. private _getDebugSphereMesh;
  43607. private _getDebugCylinderMesh;
  43608. private _getDebugMeshMesh;
  43609. private _getDebugMesh;
  43610. /** Releases all resources */
  43611. dispose(): void;
  43612. }
  43613. }
  43614. declare module BABYLON {
  43615. /**
  43616. * Class containing static functions to help procedurally build meshes
  43617. */
  43618. export class LinesBuilder {
  43619. /**
  43620. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43621. * * 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
  43622. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43623. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43624. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43625. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43626. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43627. * * 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
  43628. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43631. * @param name defines the name of the new line system
  43632. * @param options defines the options used to create the line system
  43633. * @param scene defines the hosting scene
  43634. * @returns a new line system mesh
  43635. */
  43636. static CreateLineSystem(name: string, options: {
  43637. lines: Vector3[][];
  43638. updatable?: boolean;
  43639. instance?: Nullable<LinesMesh>;
  43640. colors?: Nullable<Color4[][]>;
  43641. useVertexAlpha?: boolean;
  43642. }, scene: Nullable<Scene>): LinesMesh;
  43643. /**
  43644. * Creates a line mesh
  43645. * 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
  43646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43647. * * The parameter `points` is an array successive Vector3
  43648. * * 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
  43649. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43650. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43651. * * When updating an instance, remember that only point positions can change, not the number of points
  43652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43654. * @param name defines the name of the new line system
  43655. * @param options defines the options used to create the line system
  43656. * @param scene defines the hosting scene
  43657. * @returns a new line mesh
  43658. */
  43659. static CreateLines(name: string, options: {
  43660. points: Vector3[];
  43661. updatable?: boolean;
  43662. instance?: Nullable<LinesMesh>;
  43663. colors?: Color4[];
  43664. useVertexAlpha?: boolean;
  43665. }, scene?: Nullable<Scene>): LinesMesh;
  43666. /**
  43667. * Creates a dashed line mesh
  43668. * * 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
  43669. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43670. * * The parameter `points` is an array successive Vector3
  43671. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43672. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43673. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43674. * * 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
  43675. * * When updating an instance, remember that only point positions can change, not the number of points
  43676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43677. * @param name defines the name of the mesh
  43678. * @param options defines the options used to create the mesh
  43679. * @param scene defines the hosting scene
  43680. * @returns the dashed line mesh
  43681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43682. */
  43683. static CreateDashedLines(name: string, options: {
  43684. points: Vector3[];
  43685. dashSize?: number;
  43686. gapSize?: number;
  43687. dashNb?: number;
  43688. updatable?: boolean;
  43689. instance?: LinesMesh;
  43690. }, scene?: Nullable<Scene>): LinesMesh;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /**
  43695. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43696. * in order to better appreciate the issue one might have.
  43697. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43698. */
  43699. export class RayHelper {
  43700. /**
  43701. * Defines the ray we are currently tryin to visualize.
  43702. */
  43703. ray: Nullable<Ray>;
  43704. private _renderPoints;
  43705. private _renderLine;
  43706. private _renderFunction;
  43707. private _scene;
  43708. private _updateToMeshFunction;
  43709. private _attachedToMesh;
  43710. private _meshSpaceDirection;
  43711. private _meshSpaceOrigin;
  43712. /**
  43713. * Helper function to create a colored helper in a scene in one line.
  43714. * @param ray Defines the ray we are currently tryin to visualize
  43715. * @param scene Defines the scene the ray is used in
  43716. * @param color Defines the color we want to see the ray in
  43717. * @returns The newly created ray helper.
  43718. */
  43719. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43720. /**
  43721. * Instantiate a new ray helper.
  43722. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43723. * in order to better appreciate the issue one might have.
  43724. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43725. * @param ray Defines the ray we are currently tryin to visualize
  43726. */
  43727. constructor(ray: Ray);
  43728. /**
  43729. * Shows the ray we are willing to debug.
  43730. * @param scene Defines the scene the ray needs to be rendered in
  43731. * @param color Defines the color the ray needs to be rendered in
  43732. */
  43733. show(scene: Scene, color?: Color3): void;
  43734. /**
  43735. * Hides the ray we are debugging.
  43736. */
  43737. hide(): void;
  43738. private _render;
  43739. /**
  43740. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43741. * @param mesh Defines the mesh we want the helper attached to
  43742. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43743. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43744. * @param length Defines the length of the ray
  43745. */
  43746. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43747. /**
  43748. * Detach the ray helper from the mesh it has previously been attached to.
  43749. */
  43750. detachFromMesh(): void;
  43751. private _updateToMesh;
  43752. /**
  43753. * Dispose the helper and release its associated resources.
  43754. */
  43755. dispose(): void;
  43756. }
  43757. }
  43758. declare module BABYLON.Debug {
  43759. /**
  43760. * Class used to render a debug view of a given skeleton
  43761. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43762. */
  43763. export class SkeletonViewer {
  43764. /** defines the skeleton to render */
  43765. skeleton: Skeleton;
  43766. /** defines the mesh attached to the skeleton */
  43767. mesh: AbstractMesh;
  43768. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43769. autoUpdateBonesMatrices: boolean;
  43770. /** defines the rendering group id to use with the viewer */
  43771. renderingGroupId: number;
  43772. /** Gets or sets the color used to render the skeleton */
  43773. color: Color3;
  43774. private _scene;
  43775. private _debugLines;
  43776. private _debugMesh;
  43777. private _isEnabled;
  43778. private _renderFunction;
  43779. private _utilityLayer;
  43780. /**
  43781. * Returns the mesh used to render the bones
  43782. */
  43783. readonly debugMesh: Nullable<LinesMesh>;
  43784. /**
  43785. * Creates a new SkeletonViewer
  43786. * @param skeleton defines the skeleton to render
  43787. * @param mesh defines the mesh attached to the skeleton
  43788. * @param scene defines the hosting scene
  43789. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43790. * @param renderingGroupId defines the rendering group id to use with the viewer
  43791. */
  43792. constructor(
  43793. /** defines the skeleton to render */
  43794. skeleton: Skeleton,
  43795. /** defines the mesh attached to the skeleton */
  43796. mesh: AbstractMesh, scene: Scene,
  43797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43798. autoUpdateBonesMatrices?: boolean,
  43799. /** defines the rendering group id to use with the viewer */
  43800. renderingGroupId?: number);
  43801. /** Gets or sets a boolean indicating if the viewer is enabled */
  43802. isEnabled: boolean;
  43803. private _getBonePosition;
  43804. private _getLinesForBonesWithLength;
  43805. private _getLinesForBonesNoLength;
  43806. /** Update the viewer to sync with current skeleton state */
  43807. update(): void;
  43808. /** Release associated resources */
  43809. dispose(): void;
  43810. }
  43811. }
  43812. declare module BABYLON {
  43813. /**
  43814. * Options to create the null engine
  43815. */
  43816. export class NullEngineOptions {
  43817. /**
  43818. * Render width (Default: 512)
  43819. */
  43820. renderWidth: number;
  43821. /**
  43822. * Render height (Default: 256)
  43823. */
  43824. renderHeight: number;
  43825. /**
  43826. * Texture size (Default: 512)
  43827. */
  43828. textureSize: number;
  43829. /**
  43830. * If delta time between frames should be constant
  43831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43832. */
  43833. deterministicLockstep: boolean;
  43834. /**
  43835. * Maximum about of steps between frames (Default: 4)
  43836. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43837. */
  43838. lockstepMaxSteps: number;
  43839. }
  43840. /**
  43841. * The null engine class provides support for headless version of babylon.js.
  43842. * This can be used in server side scenario or for testing purposes
  43843. */
  43844. export class NullEngine extends Engine {
  43845. private _options;
  43846. /**
  43847. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43849. * @returns true if engine is in deterministic lock step mode
  43850. */
  43851. isDeterministicLockStep(): boolean;
  43852. /**
  43853. * Gets the max steps when engine is running in deterministic lock step
  43854. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43855. * @returns the max steps
  43856. */
  43857. getLockstepMaxSteps(): number;
  43858. /**
  43859. * Gets the current hardware scaling level.
  43860. * By default the hardware scaling level is computed from the window device ratio.
  43861. * 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.
  43862. * @returns a number indicating the current hardware scaling level
  43863. */
  43864. getHardwareScalingLevel(): number;
  43865. constructor(options?: NullEngineOptions);
  43866. /**
  43867. * Creates a vertex buffer
  43868. * @param vertices the data for the vertex buffer
  43869. * @returns the new WebGL static buffer
  43870. */
  43871. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43872. /**
  43873. * Creates a new index buffer
  43874. * @param indices defines the content of the index buffer
  43875. * @param updatable defines if the index buffer must be updatable
  43876. * @returns a new webGL buffer
  43877. */
  43878. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43879. /**
  43880. * Clear the current render buffer or the current render target (if any is set up)
  43881. * @param color defines the color to use
  43882. * @param backBuffer defines if the back buffer must be cleared
  43883. * @param depth defines if the depth buffer must be cleared
  43884. * @param stencil defines if the stencil buffer must be cleared
  43885. */
  43886. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43887. /**
  43888. * Gets the current render width
  43889. * @param useScreen defines if screen size must be used (or the current render target if any)
  43890. * @returns a number defining the current render width
  43891. */
  43892. getRenderWidth(useScreen?: boolean): number;
  43893. /**
  43894. * Gets the current render height
  43895. * @param useScreen defines if screen size must be used (or the current render target if any)
  43896. * @returns a number defining the current render height
  43897. */
  43898. getRenderHeight(useScreen?: boolean): number;
  43899. /**
  43900. * Set the WebGL's viewport
  43901. * @param viewport defines the viewport element to be used
  43902. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43903. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43904. */
  43905. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43906. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43907. /**
  43908. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43909. * @param pipelineContext defines the pipeline context to use
  43910. * @param uniformsNames defines the list of uniform names
  43911. * @returns an array of webGL uniform locations
  43912. */
  43913. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43914. /**
  43915. * Gets the lsit of active attributes for a given webGL program
  43916. * @param pipelineContext defines the pipeline context to use
  43917. * @param attributesNames defines the list of attribute names to get
  43918. * @returns an array of indices indicating the offset of each attribute
  43919. */
  43920. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43921. /**
  43922. * Binds an effect to the webGL context
  43923. * @param effect defines the effect to bind
  43924. */
  43925. bindSamplers(effect: Effect): void;
  43926. /**
  43927. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43928. * @param effect defines the effect to activate
  43929. */
  43930. enableEffect(effect: Effect): void;
  43931. /**
  43932. * Set various states to the webGL context
  43933. * @param culling defines backface culling state
  43934. * @param zOffset defines the value to apply to zOffset (0 by default)
  43935. * @param force defines if states must be applied even if cache is up to date
  43936. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43937. */
  43938. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43939. /**
  43940. * Set the value of an uniform to an array of int32
  43941. * @param uniform defines the webGL uniform location where to store the value
  43942. * @param array defines the array of int32 to store
  43943. */
  43944. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43945. /**
  43946. * Set the value of an uniform to an array of int32 (stored as vec2)
  43947. * @param uniform defines the webGL uniform location where to store the value
  43948. * @param array defines the array of int32 to store
  43949. */
  43950. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43951. /**
  43952. * Set the value of an uniform to an array of int32 (stored as vec3)
  43953. * @param uniform defines the webGL uniform location where to store the value
  43954. * @param array defines the array of int32 to store
  43955. */
  43956. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43957. /**
  43958. * Set the value of an uniform to an array of int32 (stored as vec4)
  43959. * @param uniform defines the webGL uniform location where to store the value
  43960. * @param array defines the array of int32 to store
  43961. */
  43962. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43963. /**
  43964. * Set the value of an uniform to an array of float32
  43965. * @param uniform defines the webGL uniform location where to store the value
  43966. * @param array defines the array of float32 to store
  43967. */
  43968. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43969. /**
  43970. * Set the value of an uniform to an array of float32 (stored as vec2)
  43971. * @param uniform defines the webGL uniform location where to store the value
  43972. * @param array defines the array of float32 to store
  43973. */
  43974. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43975. /**
  43976. * Set the value of an uniform to an array of float32 (stored as vec3)
  43977. * @param uniform defines the webGL uniform location where to store the value
  43978. * @param array defines the array of float32 to store
  43979. */
  43980. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43981. /**
  43982. * Set the value of an uniform to an array of float32 (stored as vec4)
  43983. * @param uniform defines the webGL uniform location where to store the value
  43984. * @param array defines the array of float32 to store
  43985. */
  43986. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43987. /**
  43988. * Set the value of an uniform to an array of number
  43989. * @param uniform defines the webGL uniform location where to store the value
  43990. * @param array defines the array of number to store
  43991. */
  43992. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43993. /**
  43994. * Set the value of an uniform to an array of number (stored as vec2)
  43995. * @param uniform defines the webGL uniform location where to store the value
  43996. * @param array defines the array of number to store
  43997. */
  43998. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43999. /**
  44000. * Set the value of an uniform to an array of number (stored as vec3)
  44001. * @param uniform defines the webGL uniform location where to store the value
  44002. * @param array defines the array of number to store
  44003. */
  44004. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44005. /**
  44006. * Set the value of an uniform to an array of number (stored as vec4)
  44007. * @param uniform defines the webGL uniform location where to store the value
  44008. * @param array defines the array of number to store
  44009. */
  44010. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44011. /**
  44012. * Set the value of an uniform to an array of float32 (stored as matrices)
  44013. * @param uniform defines the webGL uniform location where to store the value
  44014. * @param matrices defines the array of float32 to store
  44015. */
  44016. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44017. /**
  44018. * Set the value of an uniform to a matrix (3x3)
  44019. * @param uniform defines the webGL uniform location where to store the value
  44020. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44021. */
  44022. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44023. /**
  44024. * Set the value of an uniform to a matrix (2x2)
  44025. * @param uniform defines the webGL uniform location where to store the value
  44026. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44027. */
  44028. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44029. /**
  44030. * Set the value of an uniform to a number (float)
  44031. * @param uniform defines the webGL uniform location where to store the value
  44032. * @param value defines the float number to store
  44033. */
  44034. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44035. /**
  44036. * Set the value of an uniform to a vec2
  44037. * @param uniform defines the webGL uniform location where to store the value
  44038. * @param x defines the 1st component of the value
  44039. * @param y defines the 2nd component of the value
  44040. */
  44041. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44042. /**
  44043. * Set the value of an uniform to a vec3
  44044. * @param uniform defines the webGL uniform location where to store the value
  44045. * @param x defines the 1st component of the value
  44046. * @param y defines the 2nd component of the value
  44047. * @param z defines the 3rd component of the value
  44048. */
  44049. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44050. /**
  44051. * Set the value of an uniform to a boolean
  44052. * @param uniform defines the webGL uniform location where to store the value
  44053. * @param bool defines the boolean to store
  44054. */
  44055. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44056. /**
  44057. * Set the value of an uniform to a vec4
  44058. * @param uniform defines the webGL uniform location where to store the value
  44059. * @param x defines the 1st component of the value
  44060. * @param y defines the 2nd component of the value
  44061. * @param z defines the 3rd component of the value
  44062. * @param w defines the 4th component of the value
  44063. */
  44064. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44065. /**
  44066. * Sets the current alpha mode
  44067. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44068. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44070. */
  44071. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44072. /**
  44073. * Bind webGl buffers directly to the webGL context
  44074. * @param vertexBuffers defines the vertex buffer to bind
  44075. * @param indexBuffer defines the index buffer to bind
  44076. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44077. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44078. * @param effect defines the effect associated with the vertex buffer
  44079. */
  44080. bindBuffers(vertexBuffers: {
  44081. [key: string]: VertexBuffer;
  44082. }, indexBuffer: DataBuffer, effect: Effect): void;
  44083. /**
  44084. * Force the entire cache to be cleared
  44085. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44086. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44087. */
  44088. wipeCaches(bruteForce?: boolean): void;
  44089. /**
  44090. * Send a draw order
  44091. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44092. * @param indexStart defines the starting index
  44093. * @param indexCount defines the number of index to draw
  44094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44095. */
  44096. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44097. /**
  44098. * Draw a list of indexed primitives
  44099. * @param fillMode defines the primitive to use
  44100. * @param indexStart defines the starting index
  44101. * @param indexCount defines the number of index to draw
  44102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44103. */
  44104. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44105. /**
  44106. * Draw a list of unindexed primitives
  44107. * @param fillMode defines the primitive to use
  44108. * @param verticesStart defines the index of first vertex to draw
  44109. * @param verticesCount defines the count of vertices to draw
  44110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44111. */
  44112. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44113. /** @hidden */
  44114. _createTexture(): WebGLTexture;
  44115. /** @hidden */
  44116. _releaseTexture(texture: InternalTexture): void;
  44117. /**
  44118. * Usually called from Texture.ts.
  44119. * Passed information to create a WebGLTexture
  44120. * @param urlArg defines a value which contains one of the following:
  44121. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44122. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44123. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44124. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44125. * @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)
  44126. * @param scene needed for loading to the correct scene
  44127. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44128. * @param onLoad optional callback to be called upon successful completion
  44129. * @param onError optional callback to be called upon failure
  44130. * @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
  44131. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44132. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44133. * @param forcedExtension defines the extension to use to pick the right loader
  44134. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44135. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44136. */
  44137. 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;
  44138. /**
  44139. * Creates a new render target texture
  44140. * @param size defines the size of the texture
  44141. * @param options defines the options used to create the texture
  44142. * @returns a new render target texture stored in an InternalTexture
  44143. */
  44144. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44145. /**
  44146. * Update the sampling mode of a given texture
  44147. * @param samplingMode defines the required sampling mode
  44148. * @param texture defines the texture to update
  44149. */
  44150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44151. /**
  44152. * Binds the frame buffer to the specified texture.
  44153. * @param texture The texture to render to or null for the default canvas
  44154. * @param faceIndex The face of the texture to render to in case of cube texture
  44155. * @param requiredWidth The width of the target to render to
  44156. * @param requiredHeight The height of the target to render to
  44157. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44158. * @param depthStencilTexture The depth stencil texture to use to render
  44159. * @param lodLevel defines le lod level to bind to the frame buffer
  44160. */
  44161. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44162. /**
  44163. * Unbind the current render target texture from the webGL context
  44164. * @param texture defines the render target texture to unbind
  44165. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44166. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44167. */
  44168. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44169. /**
  44170. * Creates a dynamic vertex buffer
  44171. * @param vertices the data for the dynamic vertex buffer
  44172. * @returns the new WebGL dynamic buffer
  44173. */
  44174. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44175. /**
  44176. * Update the content of a dynamic texture
  44177. * @param texture defines the texture to update
  44178. * @param canvas defines the canvas containing the source
  44179. * @param invertY defines if data must be stored with Y axis inverted
  44180. * @param premulAlpha defines if alpha is stored as premultiplied
  44181. * @param format defines the format of the data
  44182. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44183. */
  44184. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44185. /**
  44186. * Gets a boolean indicating if all created effects are ready
  44187. * @returns true if all effects are ready
  44188. */
  44189. areAllEffectsReady(): boolean;
  44190. /**
  44191. * @hidden
  44192. * Get the current error code of the webGL context
  44193. * @returns the error code
  44194. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44195. */
  44196. getError(): number;
  44197. /** @hidden */
  44198. _getUnpackAlignement(): number;
  44199. /** @hidden */
  44200. _unpackFlipY(value: boolean): void;
  44201. /**
  44202. * Update a dynamic index buffer
  44203. * @param indexBuffer defines the target index buffer
  44204. * @param indices defines the data to update
  44205. * @param offset defines the offset in the target index buffer where update should start
  44206. */
  44207. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44208. /**
  44209. * Updates a dynamic vertex buffer.
  44210. * @param vertexBuffer the vertex buffer to update
  44211. * @param vertices the data used to update the vertex buffer
  44212. * @param byteOffset the byte offset of the data (optional)
  44213. * @param byteLength the byte length of the data (optional)
  44214. */
  44215. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44216. /** @hidden */
  44217. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44218. /** @hidden */
  44219. _bindTexture(channel: number, texture: InternalTexture): void;
  44220. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44221. /**
  44222. * 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
  44223. */
  44224. releaseEffects(): void;
  44225. displayLoadingUI(): void;
  44226. hideLoadingUI(): void;
  44227. /** @hidden */
  44228. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44229. /** @hidden */
  44230. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44231. /** @hidden */
  44232. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44233. /** @hidden */
  44234. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44235. }
  44236. }
  44237. declare module BABYLON {
  44238. /** @hidden */
  44239. export class _OcclusionDataStorage {
  44240. /** @hidden */
  44241. occlusionInternalRetryCounter: number;
  44242. /** @hidden */
  44243. isOcclusionQueryInProgress: boolean;
  44244. /** @hidden */
  44245. isOccluded: boolean;
  44246. /** @hidden */
  44247. occlusionRetryCount: number;
  44248. /** @hidden */
  44249. occlusionType: number;
  44250. /** @hidden */
  44251. occlusionQueryAlgorithmType: number;
  44252. }
  44253. interface Engine {
  44254. /**
  44255. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44256. * @return the new query
  44257. */
  44258. createQuery(): WebGLQuery;
  44259. /**
  44260. * Delete and release a webGL query
  44261. * @param query defines the query to delete
  44262. * @return the current engine
  44263. */
  44264. deleteQuery(query: WebGLQuery): Engine;
  44265. /**
  44266. * Check if a given query has resolved and got its value
  44267. * @param query defines the query to check
  44268. * @returns true if the query got its value
  44269. */
  44270. isQueryResultAvailable(query: WebGLQuery): boolean;
  44271. /**
  44272. * Gets the value of a given query
  44273. * @param query defines the query to check
  44274. * @returns the value of the query
  44275. */
  44276. getQueryResult(query: WebGLQuery): number;
  44277. /**
  44278. * Initiates an occlusion query
  44279. * @param algorithmType defines the algorithm to use
  44280. * @param query defines the query to use
  44281. * @returns the current engine
  44282. * @see http://doc.babylonjs.com/features/occlusionquery
  44283. */
  44284. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44285. /**
  44286. * Ends an occlusion query
  44287. * @see http://doc.babylonjs.com/features/occlusionquery
  44288. * @param algorithmType defines the algorithm to use
  44289. * @returns the current engine
  44290. */
  44291. endOcclusionQuery(algorithmType: number): Engine;
  44292. /**
  44293. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44294. * Please note that only one query can be issued at a time
  44295. * @returns a time token used to track the time span
  44296. */
  44297. startTimeQuery(): Nullable<_TimeToken>;
  44298. /**
  44299. * Ends a time query
  44300. * @param token defines the token used to measure the time span
  44301. * @returns the time spent (in ns)
  44302. */
  44303. endTimeQuery(token: _TimeToken): int;
  44304. /** @hidden */
  44305. _currentNonTimestampToken: Nullable<_TimeToken>;
  44306. /** @hidden */
  44307. _createTimeQuery(): WebGLQuery;
  44308. /** @hidden */
  44309. _deleteTimeQuery(query: WebGLQuery): void;
  44310. /** @hidden */
  44311. _getGlAlgorithmType(algorithmType: number): number;
  44312. /** @hidden */
  44313. _getTimeQueryResult(query: WebGLQuery): any;
  44314. /** @hidden */
  44315. _getTimeQueryAvailability(query: WebGLQuery): any;
  44316. }
  44317. interface AbstractMesh {
  44318. /**
  44319. * Backing filed
  44320. * @hidden
  44321. */
  44322. __occlusionDataStorage: _OcclusionDataStorage;
  44323. /**
  44324. * Access property
  44325. * @hidden
  44326. */
  44327. _occlusionDataStorage: _OcclusionDataStorage;
  44328. /**
  44329. * 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.
  44330. * The default value is -1 which means don't break the query and wait till the result
  44331. * @see http://doc.babylonjs.com/features/occlusionquery
  44332. */
  44333. occlusionRetryCount: number;
  44334. /**
  44335. * 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:
  44336. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44337. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44338. * * 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.
  44339. * @see http://doc.babylonjs.com/features/occlusionquery
  44340. */
  44341. occlusionType: number;
  44342. /**
  44343. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44344. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44345. * * 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.
  44346. * @see http://doc.babylonjs.com/features/occlusionquery
  44347. */
  44348. occlusionQueryAlgorithmType: number;
  44349. /**
  44350. * 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
  44351. * @see http://doc.babylonjs.com/features/occlusionquery
  44352. */
  44353. isOccluded: boolean;
  44354. /**
  44355. * Flag to check the progress status of the query
  44356. * @see http://doc.babylonjs.com/features/occlusionquery
  44357. */
  44358. isOcclusionQueryInProgress: boolean;
  44359. }
  44360. }
  44361. declare module BABYLON {
  44362. /** @hidden */
  44363. export var _forceTransformFeedbackToBundle: boolean;
  44364. interface Engine {
  44365. /**
  44366. * Creates a webGL transform feedback object
  44367. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44368. * @returns the webGL transform feedback object
  44369. */
  44370. createTransformFeedback(): WebGLTransformFeedback;
  44371. /**
  44372. * Delete a webGL transform feedback object
  44373. * @param value defines the webGL transform feedback object to delete
  44374. */
  44375. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44376. /**
  44377. * Bind a webGL transform feedback object to the webgl context
  44378. * @param value defines the webGL transform feedback object to bind
  44379. */
  44380. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44381. /**
  44382. * Begins a transform feedback operation
  44383. * @param usePoints defines if points or triangles must be used
  44384. */
  44385. beginTransformFeedback(usePoints: boolean): void;
  44386. /**
  44387. * Ends a transform feedback operation
  44388. */
  44389. endTransformFeedback(): void;
  44390. /**
  44391. * Specify the varyings to use with transform feedback
  44392. * @param program defines the associated webGL program
  44393. * @param value defines the list of strings representing the varying names
  44394. */
  44395. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44396. /**
  44397. * Bind a webGL buffer for a transform feedback operation
  44398. * @param value defines the webGL buffer to bind
  44399. */
  44400. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44401. }
  44402. }
  44403. declare module BABYLON {
  44404. /**
  44405. * Creation options of the multi render target texture.
  44406. */
  44407. export interface IMultiRenderTargetOptions {
  44408. /**
  44409. * Define if the texture needs to create mip maps after render.
  44410. */
  44411. generateMipMaps?: boolean;
  44412. /**
  44413. * Define the types of all the draw buffers we want to create
  44414. */
  44415. types?: number[];
  44416. /**
  44417. * Define the sampling modes of all the draw buffers we want to create
  44418. */
  44419. samplingModes?: number[];
  44420. /**
  44421. * Define if a depth buffer is required
  44422. */
  44423. generateDepthBuffer?: boolean;
  44424. /**
  44425. * Define if a stencil buffer is required
  44426. */
  44427. generateStencilBuffer?: boolean;
  44428. /**
  44429. * Define if a depth texture is required instead of a depth buffer
  44430. */
  44431. generateDepthTexture?: boolean;
  44432. /**
  44433. * Define the number of desired draw buffers
  44434. */
  44435. textureCount?: number;
  44436. /**
  44437. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44438. */
  44439. doNotChangeAspectRatio?: boolean;
  44440. /**
  44441. * Define the default type of the buffers we are creating
  44442. */
  44443. defaultType?: number;
  44444. }
  44445. /**
  44446. * A multi render target, like a render target provides the ability to render to a texture.
  44447. * Unlike the render target, it can render to several draw buffers in one draw.
  44448. * This is specially interesting in deferred rendering or for any effects requiring more than
  44449. * just one color from a single pass.
  44450. */
  44451. export class MultiRenderTarget extends RenderTargetTexture {
  44452. private _internalTextures;
  44453. private _textures;
  44454. private _multiRenderTargetOptions;
  44455. /**
  44456. * Get if draw buffers are currently supported by the used hardware and browser.
  44457. */
  44458. readonly isSupported: boolean;
  44459. /**
  44460. * Get the list of textures generated by the multi render target.
  44461. */
  44462. readonly textures: Texture[];
  44463. /**
  44464. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44465. */
  44466. readonly depthTexture: Texture;
  44467. /**
  44468. * Set the wrapping mode on U of all the textures we are rendering to.
  44469. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44470. */
  44471. wrapU: number;
  44472. /**
  44473. * Set the wrapping mode on V of all the textures we are rendering to.
  44474. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44475. */
  44476. wrapV: number;
  44477. /**
  44478. * Instantiate a new multi render target texture.
  44479. * A multi render target, like a render target provides the ability to render to a texture.
  44480. * Unlike the render target, it can render to several draw buffers in one draw.
  44481. * This is specially interesting in deferred rendering or for any effects requiring more than
  44482. * just one color from a single pass.
  44483. * @param name Define the name of the texture
  44484. * @param size Define the size of the buffers to render to
  44485. * @param count Define the number of target we are rendering into
  44486. * @param scene Define the scene the texture belongs to
  44487. * @param options Define the options used to create the multi render target
  44488. */
  44489. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44490. /** @hidden */
  44491. _rebuild(): void;
  44492. private _createInternalTextures;
  44493. private _createTextures;
  44494. /**
  44495. * Define the number of samples used if MSAA is enabled.
  44496. */
  44497. samples: number;
  44498. /**
  44499. * Resize all the textures in the multi render target.
  44500. * Be carrefull as it will recreate all the data in the new texture.
  44501. * @param size Define the new size
  44502. */
  44503. resize(size: any): void;
  44504. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44505. /**
  44506. * Dispose the render targets and their associated resources
  44507. */
  44508. dispose(): void;
  44509. /**
  44510. * Release all the underlying texture used as draw buffers.
  44511. */
  44512. releaseInternalTextures(): void;
  44513. }
  44514. }
  44515. declare module BABYLON {
  44516. interface ThinEngine {
  44517. /**
  44518. * Unbind a list of render target textures from the webGL context
  44519. * This is used only when drawBuffer extension or webGL2 are active
  44520. * @param textures defines the render target textures to unbind
  44521. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44522. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44523. */
  44524. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44525. /**
  44526. * Create a multi render target texture
  44527. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44528. * @param size defines the size of the texture
  44529. * @param options defines the creation options
  44530. * @returns the cube texture as an InternalTexture
  44531. */
  44532. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44533. /**
  44534. * Update the sample count for a given multiple render target texture
  44535. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44536. * @param textures defines the textures to update
  44537. * @param samples defines the sample count to set
  44538. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44539. */
  44540. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. /**
  44545. * Class used to define an additional view for the engine
  44546. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44547. */
  44548. export class EngineView {
  44549. /** Defines the canvas where to render the view */
  44550. target: HTMLCanvasElement;
  44551. /** Defines the camera used to render the view */
  44552. camera: Camera;
  44553. }
  44554. interface Engine {
  44555. /** Gets or sets the list of views */
  44556. views: EngineView[];
  44557. /**
  44558. * Register a new child canvas
  44559. * @param canvas defines the canvas to register
  44560. * @param camera defines the camera to use with this canvas (it will overwrite the scene.camera for this view)
  44561. * @returns the current engine
  44562. */
  44563. registerView(canvas: HTMLCanvasElement, camera: Camera): Engine;
  44564. /**
  44565. * Remove a registered child canvas
  44566. * @param canvas defines the canvas to remove
  44567. * @returns the current engine
  44568. */
  44569. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44570. }
  44571. }
  44572. declare module BABYLON {
  44573. /**
  44574. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44575. */
  44576. export interface CubeMapInfo {
  44577. /**
  44578. * The pixel array for the front face.
  44579. * This is stored in format, left to right, up to down format.
  44580. */
  44581. front: Nullable<ArrayBufferView>;
  44582. /**
  44583. * The pixel array for the back face.
  44584. * This is stored in format, left to right, up to down format.
  44585. */
  44586. back: Nullable<ArrayBufferView>;
  44587. /**
  44588. * The pixel array for the left face.
  44589. * This is stored in format, left to right, up to down format.
  44590. */
  44591. left: Nullable<ArrayBufferView>;
  44592. /**
  44593. * The pixel array for the right face.
  44594. * This is stored in format, left to right, up to down format.
  44595. */
  44596. right: Nullable<ArrayBufferView>;
  44597. /**
  44598. * The pixel array for the up face.
  44599. * This is stored in format, left to right, up to down format.
  44600. */
  44601. up: Nullable<ArrayBufferView>;
  44602. /**
  44603. * The pixel array for the down face.
  44604. * This is stored in format, left to right, up to down format.
  44605. */
  44606. down: Nullable<ArrayBufferView>;
  44607. /**
  44608. * The size of the cubemap stored.
  44609. *
  44610. * Each faces will be size * size pixels.
  44611. */
  44612. size: number;
  44613. /**
  44614. * The format of the texture.
  44615. *
  44616. * RGBA, RGB.
  44617. */
  44618. format: number;
  44619. /**
  44620. * The type of the texture data.
  44621. *
  44622. * UNSIGNED_INT, FLOAT.
  44623. */
  44624. type: number;
  44625. /**
  44626. * Specifies whether the texture is in gamma space.
  44627. */
  44628. gammaSpace: boolean;
  44629. }
  44630. /**
  44631. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44632. */
  44633. export class PanoramaToCubeMapTools {
  44634. private static FACE_FRONT;
  44635. private static FACE_BACK;
  44636. private static FACE_RIGHT;
  44637. private static FACE_LEFT;
  44638. private static FACE_DOWN;
  44639. private static FACE_UP;
  44640. /**
  44641. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44642. *
  44643. * @param float32Array The source data.
  44644. * @param inputWidth The width of the input panorama.
  44645. * @param inputHeight The height of the input panorama.
  44646. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44647. * @return The cubemap data
  44648. */
  44649. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44650. private static CreateCubemapTexture;
  44651. private static CalcProjectionSpherical;
  44652. }
  44653. }
  44654. declare module BABYLON {
  44655. /**
  44656. * Helper class dealing with the extraction of spherical polynomial dataArray
  44657. * from a cube map.
  44658. */
  44659. export class CubeMapToSphericalPolynomialTools {
  44660. private static FileFaces;
  44661. /**
  44662. * Converts a texture to the according Spherical Polynomial data.
  44663. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44664. *
  44665. * @param texture The texture to extract the information from.
  44666. * @return The Spherical Polynomial data.
  44667. */
  44668. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44669. /**
  44670. * Converts a cubemap to the according Spherical Polynomial data.
  44671. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44672. *
  44673. * @param cubeInfo The Cube map to extract the information from.
  44674. * @return The Spherical Polynomial data.
  44675. */
  44676. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44677. }
  44678. }
  44679. declare module BABYLON {
  44680. interface BaseTexture {
  44681. /**
  44682. * Get the polynomial representation of the texture data.
  44683. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44684. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44685. */
  44686. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44687. }
  44688. }
  44689. declare module BABYLON {
  44690. /** @hidden */
  44691. export var rgbdEncodePixelShader: {
  44692. name: string;
  44693. shader: string;
  44694. };
  44695. }
  44696. declare module BABYLON {
  44697. /** @hidden */
  44698. export var rgbdDecodePixelShader: {
  44699. name: string;
  44700. shader: string;
  44701. };
  44702. }
  44703. declare module BABYLON {
  44704. /**
  44705. * Raw texture data and descriptor sufficient for WebGL texture upload
  44706. */
  44707. export interface EnvironmentTextureInfo {
  44708. /**
  44709. * Version of the environment map
  44710. */
  44711. version: number;
  44712. /**
  44713. * Width of image
  44714. */
  44715. width: number;
  44716. /**
  44717. * Irradiance information stored in the file.
  44718. */
  44719. irradiance: any;
  44720. /**
  44721. * Specular information stored in the file.
  44722. */
  44723. specular: any;
  44724. }
  44725. /**
  44726. * Defines One Image in the file. It requires only the position in the file
  44727. * as well as the length.
  44728. */
  44729. interface BufferImageData {
  44730. /**
  44731. * Length of the image data.
  44732. */
  44733. length: number;
  44734. /**
  44735. * Position of the data from the null terminator delimiting the end of the JSON.
  44736. */
  44737. position: number;
  44738. }
  44739. /**
  44740. * Defines the specular data enclosed in the file.
  44741. * This corresponds to the version 1 of the data.
  44742. */
  44743. export interface EnvironmentTextureSpecularInfoV1 {
  44744. /**
  44745. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44746. */
  44747. specularDataPosition?: number;
  44748. /**
  44749. * This contains all the images data needed to reconstruct the cubemap.
  44750. */
  44751. mipmaps: Array<BufferImageData>;
  44752. /**
  44753. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44754. */
  44755. lodGenerationScale: number;
  44756. }
  44757. /**
  44758. * Sets of helpers addressing the serialization and deserialization of environment texture
  44759. * stored in a BabylonJS env file.
  44760. * Those files are usually stored as .env files.
  44761. */
  44762. export class EnvironmentTextureTools {
  44763. /**
  44764. * Magic number identifying the env file.
  44765. */
  44766. private static _MagicBytes;
  44767. /**
  44768. * Gets the environment info from an env file.
  44769. * @param data The array buffer containing the .env bytes.
  44770. * @returns the environment file info (the json header) if successfully parsed.
  44771. */
  44772. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44773. /**
  44774. * Creates an environment texture from a loaded cube texture.
  44775. * @param texture defines the cube texture to convert in env file
  44776. * @return a promise containing the environment data if succesfull.
  44777. */
  44778. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44779. /**
  44780. * Creates a JSON representation of the spherical data.
  44781. * @param texture defines the texture containing the polynomials
  44782. * @return the JSON representation of the spherical info
  44783. */
  44784. private static _CreateEnvTextureIrradiance;
  44785. /**
  44786. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44787. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44788. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44789. * @return the views described by info providing access to the underlying buffer
  44790. */
  44791. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44792. /**
  44793. * Uploads the texture info contained in the env file to the GPU.
  44794. * @param texture defines the internal texture to upload to
  44795. * @param arrayBuffer defines the buffer cotaining the data to load
  44796. * @param info defines the texture info retrieved through the GetEnvInfo method
  44797. * @returns a promise
  44798. */
  44799. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44800. private static _OnImageReadyAsync;
  44801. /**
  44802. * Uploads the levels of image data to the GPU.
  44803. * @param texture defines the internal texture to upload to
  44804. * @param imageData defines the array buffer views of image data [mipmap][face]
  44805. * @returns a promise
  44806. */
  44807. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44808. /**
  44809. * Uploads spherical polynomials information to the texture.
  44810. * @param texture defines the texture we are trying to upload the information to
  44811. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44812. */
  44813. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44814. /** @hidden */
  44815. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44816. }
  44817. }
  44818. declare module BABYLON {
  44819. /**
  44820. * Contains position and normal vectors for a vertex
  44821. */
  44822. export class PositionNormalVertex {
  44823. /** the position of the vertex (defaut: 0,0,0) */
  44824. position: Vector3;
  44825. /** the normal of the vertex (defaut: 0,1,0) */
  44826. normal: Vector3;
  44827. /**
  44828. * Creates a PositionNormalVertex
  44829. * @param position the position of the vertex (defaut: 0,0,0)
  44830. * @param normal the normal of the vertex (defaut: 0,1,0)
  44831. */
  44832. constructor(
  44833. /** the position of the vertex (defaut: 0,0,0) */
  44834. position?: Vector3,
  44835. /** the normal of the vertex (defaut: 0,1,0) */
  44836. normal?: Vector3);
  44837. /**
  44838. * Clones the PositionNormalVertex
  44839. * @returns the cloned PositionNormalVertex
  44840. */
  44841. clone(): PositionNormalVertex;
  44842. }
  44843. /**
  44844. * Contains position, normal and uv vectors for a vertex
  44845. */
  44846. export class PositionNormalTextureVertex {
  44847. /** the position of the vertex (defaut: 0,0,0) */
  44848. position: Vector3;
  44849. /** the normal of the vertex (defaut: 0,1,0) */
  44850. normal: Vector3;
  44851. /** the uv of the vertex (default: 0,0) */
  44852. uv: Vector2;
  44853. /**
  44854. * Creates a PositionNormalTextureVertex
  44855. * @param position the position of the vertex (defaut: 0,0,0)
  44856. * @param normal the normal of the vertex (defaut: 0,1,0)
  44857. * @param uv the uv of the vertex (default: 0,0)
  44858. */
  44859. constructor(
  44860. /** the position of the vertex (defaut: 0,0,0) */
  44861. position?: Vector3,
  44862. /** the normal of the vertex (defaut: 0,1,0) */
  44863. normal?: Vector3,
  44864. /** the uv of the vertex (default: 0,0) */
  44865. uv?: Vector2);
  44866. /**
  44867. * Clones the PositionNormalTextureVertex
  44868. * @returns the cloned PositionNormalTextureVertex
  44869. */
  44870. clone(): PositionNormalTextureVertex;
  44871. }
  44872. }
  44873. declare module BABYLON {
  44874. /** @hidden */
  44875. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44876. private _genericAttributeLocation;
  44877. private _varyingLocationCount;
  44878. private _varyingLocationMap;
  44879. private _replacements;
  44880. private _textureCount;
  44881. private _uniforms;
  44882. lineProcessor(line: string): string;
  44883. attributeProcessor(attribute: string): string;
  44884. varyingProcessor(varying: string, isFragment: boolean): string;
  44885. uniformProcessor(uniform: string): string;
  44886. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44887. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44888. }
  44889. }
  44890. declare module BABYLON {
  44891. /**
  44892. * Container for accessors for natively-stored mesh data buffers.
  44893. */
  44894. class NativeDataBuffer extends DataBuffer {
  44895. /**
  44896. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44897. */
  44898. nativeIndexBuffer?: any;
  44899. /**
  44900. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44901. */
  44902. nativeVertexBuffer?: any;
  44903. }
  44904. /** @hidden */
  44905. class NativeTexture extends InternalTexture {
  44906. getInternalTexture(): InternalTexture;
  44907. getViewCount(): number;
  44908. }
  44909. /** @hidden */
  44910. export class NativeEngine extends Engine {
  44911. private readonly _native;
  44912. getHardwareScalingLevel(): number;
  44913. constructor();
  44914. /**
  44915. * Can be used to override the current requestAnimationFrame requester.
  44916. * @hidden
  44917. */
  44918. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  44919. /**
  44920. * Override default engine behavior.
  44921. * @param color
  44922. * @param backBuffer
  44923. * @param depth
  44924. * @param stencil
  44925. */
  44926. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  44927. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44928. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44929. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44930. recordVertexArrayObject(vertexBuffers: {
  44931. [key: string]: VertexBuffer;
  44932. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44933. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44934. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44935. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44936. /**
  44937. * Draw a list of indexed primitives
  44938. * @param fillMode defines the primitive to use
  44939. * @param indexStart defines the starting index
  44940. * @param indexCount defines the number of index to draw
  44941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44942. */
  44943. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44944. /**
  44945. * Draw a list of unindexed primitives
  44946. * @param fillMode defines the primitive to use
  44947. * @param verticesStart defines the index of first vertex to draw
  44948. * @param verticesCount defines the count of vertices to draw
  44949. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44950. */
  44951. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44952. createPipelineContext(): IPipelineContext;
  44953. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44954. /** @hidden */
  44955. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44956. /** @hidden */
  44957. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44958. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44959. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44960. protected _setProgram(program: WebGLProgram): void;
  44961. _releaseEffect(effect: Effect): void;
  44962. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44963. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44964. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44965. bindSamplers(effect: Effect): void;
  44966. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44967. getRenderWidth(useScreen?: boolean): number;
  44968. getRenderHeight(useScreen?: boolean): number;
  44969. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44971. /**
  44972. * Set the z offset to apply to current rendering
  44973. * @param value defines the offset to apply
  44974. */
  44975. setZOffset(value: number): void;
  44976. /**
  44977. * Gets the current value of the zOffset
  44978. * @returns the current zOffset state
  44979. */
  44980. getZOffset(): number;
  44981. /**
  44982. * Enable or disable depth buffering
  44983. * @param enable defines the state to set
  44984. */
  44985. setDepthBuffer(enable: boolean): void;
  44986. /**
  44987. * Gets a boolean indicating if depth writing is enabled
  44988. * @returns the current depth writing state
  44989. */
  44990. getDepthWrite(): boolean;
  44991. /**
  44992. * Enable or disable depth writing
  44993. * @param enable defines the state to set
  44994. */
  44995. setDepthWrite(enable: boolean): void;
  44996. /**
  44997. * Enable or disable color writing
  44998. * @param enable defines the state to set
  44999. */
  45000. setColorWrite(enable: boolean): void;
  45001. /**
  45002. * Gets a boolean indicating if color writing is enabled
  45003. * @returns the current color writing state
  45004. */
  45005. getColorWrite(): boolean;
  45006. /**
  45007. * Sets alpha constants used by some alpha blending modes
  45008. * @param r defines the red component
  45009. * @param g defines the green component
  45010. * @param b defines the blue component
  45011. * @param a defines the alpha component
  45012. */
  45013. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45014. /**
  45015. * Sets the current alpha mode
  45016. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45017. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45019. */
  45020. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45021. /**
  45022. * Gets the current alpha mode
  45023. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45024. * @returns the current alpha mode
  45025. */
  45026. getAlphaMode(): number;
  45027. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45028. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45029. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45030. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45032. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45033. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45034. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45035. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45036. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45037. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45038. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45039. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45040. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45041. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45042. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45043. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45044. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45045. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45046. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45047. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45048. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45049. wipeCaches(bruteForce?: boolean): void;
  45050. _createTexture(): WebGLTexture;
  45051. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45052. /**
  45053. * Usually called from BABYLON.Texture.ts.
  45054. * Passed information to create a WebGLTexture
  45055. * @param urlArg defines a value which contains one of the following:
  45056. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45057. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45058. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45059. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45060. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45061. * @param scene needed for loading to the correct scene
  45062. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45063. * @param onLoad optional callback to be called upon successful completion
  45064. * @param onError optional callback to be called upon failure
  45065. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45066. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45067. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45068. * @param forcedExtension defines the extension to use to pick the right loader
  45069. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45070. */
  45071. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45072. /**
  45073. * Creates a cube texture
  45074. * @param rootUrl defines the url where the files to load is located
  45075. * @param scene defines the current scene
  45076. * @param files defines the list of files to load (1 per face)
  45077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45078. * @param onLoad defines an optional callback raised when the texture is loaded
  45079. * @param onError defines an optional callback raised if there is an issue to load the texture
  45080. * @param format defines the format of the data
  45081. * @param forcedExtension defines the extension to use to pick the right loader
  45082. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45083. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45084. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45085. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45086. * @returns the cube texture as an InternalTexture
  45087. */
  45088. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45089. private _getSamplingFilter;
  45090. private static _GetNativeTextureFormat;
  45091. createRenderTargetTexture(size: number | {
  45092. width: number;
  45093. height: number;
  45094. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45096. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45097. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45098. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45099. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45100. /**
  45101. * Updates a dynamic vertex buffer.
  45102. * @param vertexBuffer the vertex buffer to update
  45103. * @param data the data used to update the vertex buffer
  45104. * @param byteOffset the byte offset of the data (optional)
  45105. * @param byteLength the byte length of the data (optional)
  45106. */
  45107. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45108. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45109. private _updateAnisotropicLevel;
  45110. private _getAddressMode;
  45111. /** @hidden */
  45112. _bindTexture(channel: number, texture: InternalTexture): void;
  45113. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45114. releaseEffects(): void;
  45115. /** @hidden */
  45116. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45117. /** @hidden */
  45118. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45119. /** @hidden */
  45120. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45121. /** @hidden */
  45122. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45123. }
  45124. }
  45125. declare module BABYLON {
  45126. /**
  45127. * Gather the list of clipboard event types as constants.
  45128. */
  45129. export class ClipboardEventTypes {
  45130. /**
  45131. * The clipboard event is fired when a copy command is active (pressed).
  45132. */
  45133. static readonly COPY: number;
  45134. /**
  45135. * The clipboard event is fired when a cut command is active (pressed).
  45136. */
  45137. static readonly CUT: number;
  45138. /**
  45139. * The clipboard event is fired when a paste command is active (pressed).
  45140. */
  45141. static readonly PASTE: number;
  45142. }
  45143. /**
  45144. * This class is used to store clipboard related info for the onClipboardObservable event.
  45145. */
  45146. export class ClipboardInfo {
  45147. /**
  45148. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45149. */
  45150. type: number;
  45151. /**
  45152. * Defines the related dom event
  45153. */
  45154. event: ClipboardEvent;
  45155. /**
  45156. *Creates an instance of ClipboardInfo.
  45157. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45158. * @param event Defines the related dom event
  45159. */
  45160. constructor(
  45161. /**
  45162. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45163. */
  45164. type: number,
  45165. /**
  45166. * Defines the related dom event
  45167. */
  45168. event: ClipboardEvent);
  45169. /**
  45170. * Get the clipboard event's type from the keycode.
  45171. * @param keyCode Defines the keyCode for the current keyboard event.
  45172. * @return {number}
  45173. */
  45174. static GetTypeFromCharacter(keyCode: number): number;
  45175. }
  45176. }
  45177. declare module BABYLON {
  45178. /**
  45179. * Google Daydream controller
  45180. */
  45181. export class DaydreamController extends WebVRController {
  45182. /**
  45183. * Base Url for the controller model.
  45184. */
  45185. static MODEL_BASE_URL: string;
  45186. /**
  45187. * File name for the controller model.
  45188. */
  45189. static MODEL_FILENAME: string;
  45190. /**
  45191. * Gamepad Id prefix used to identify Daydream Controller.
  45192. */
  45193. static readonly GAMEPAD_ID_PREFIX: string;
  45194. /**
  45195. * Creates a new DaydreamController from a gamepad
  45196. * @param vrGamepad the gamepad that the controller should be created from
  45197. */
  45198. constructor(vrGamepad: any);
  45199. /**
  45200. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45201. * @param scene scene in which to add meshes
  45202. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45203. */
  45204. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45205. /**
  45206. * Called once for each button that changed state since the last frame
  45207. * @param buttonIdx Which button index changed
  45208. * @param state New state of the button
  45209. * @param changes Which properties on the state changed since last frame
  45210. */
  45211. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45212. }
  45213. }
  45214. declare module BABYLON {
  45215. /**
  45216. * Gear VR Controller
  45217. */
  45218. export class GearVRController extends WebVRController {
  45219. /**
  45220. * Base Url for the controller model.
  45221. */
  45222. static MODEL_BASE_URL: string;
  45223. /**
  45224. * File name for the controller model.
  45225. */
  45226. static MODEL_FILENAME: string;
  45227. /**
  45228. * Gamepad Id prefix used to identify this controller.
  45229. */
  45230. static readonly GAMEPAD_ID_PREFIX: string;
  45231. private readonly _buttonIndexToObservableNameMap;
  45232. /**
  45233. * Creates a new GearVRController from a gamepad
  45234. * @param vrGamepad the gamepad that the controller should be created from
  45235. */
  45236. constructor(vrGamepad: any);
  45237. /**
  45238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45239. * @param scene scene in which to add meshes
  45240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45241. */
  45242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45243. /**
  45244. * Called once for each button that changed state since the last frame
  45245. * @param buttonIdx Which button index changed
  45246. * @param state New state of the button
  45247. * @param changes Which properties on the state changed since last frame
  45248. */
  45249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45250. }
  45251. }
  45252. declare module BABYLON {
  45253. /**
  45254. * Class containing static functions to help procedurally build meshes
  45255. */
  45256. export class PolyhedronBuilder {
  45257. /**
  45258. * Creates a polyhedron mesh
  45259. * * 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
  45260. * * The parameter `size` (positive float, default 1) sets the polygon size
  45261. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45262. * * 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`
  45263. * * 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
  45264. * * 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)`)
  45265. * * 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
  45266. * * 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
  45267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45268. * * 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
  45269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45270. * @param name defines the name of the mesh
  45271. * @param options defines the options used to create the mesh
  45272. * @param scene defines the hosting scene
  45273. * @returns the polyhedron mesh
  45274. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45275. */
  45276. static CreatePolyhedron(name: string, options: {
  45277. type?: number;
  45278. size?: number;
  45279. sizeX?: number;
  45280. sizeY?: number;
  45281. sizeZ?: number;
  45282. custom?: any;
  45283. faceUV?: Vector4[];
  45284. faceColors?: Color4[];
  45285. flat?: boolean;
  45286. updatable?: boolean;
  45287. sideOrientation?: number;
  45288. frontUVs?: Vector4;
  45289. backUVs?: Vector4;
  45290. }, scene?: Nullable<Scene>): Mesh;
  45291. }
  45292. }
  45293. declare module BABYLON {
  45294. /**
  45295. * Gizmo that enables scaling a mesh along 3 axis
  45296. */
  45297. export class ScaleGizmo extends Gizmo {
  45298. /**
  45299. * Internal gizmo used for interactions on the x axis
  45300. */
  45301. xGizmo: AxisScaleGizmo;
  45302. /**
  45303. * Internal gizmo used for interactions on the y axis
  45304. */
  45305. yGizmo: AxisScaleGizmo;
  45306. /**
  45307. * Internal gizmo used for interactions on the z axis
  45308. */
  45309. zGizmo: AxisScaleGizmo;
  45310. /**
  45311. * Internal gizmo used to scale all axis equally
  45312. */
  45313. uniformScaleGizmo: AxisScaleGizmo;
  45314. private _meshAttached;
  45315. private _updateGizmoRotationToMatchAttachedMesh;
  45316. private _snapDistance;
  45317. private _scaleRatio;
  45318. private _uniformScalingMesh;
  45319. private _octahedron;
  45320. /** Fires an event when any of it's sub gizmos are dragged */
  45321. onDragStartObservable: Observable<unknown>;
  45322. /** Fires an event when any of it's sub gizmos are released from dragging */
  45323. onDragEndObservable: Observable<unknown>;
  45324. attachedMesh: Nullable<AbstractMesh>;
  45325. /**
  45326. * Creates a ScaleGizmo
  45327. * @param gizmoLayer The utility layer the gizmo will be added to
  45328. */
  45329. constructor(gizmoLayer?: UtilityLayerRenderer);
  45330. updateGizmoRotationToMatchAttachedMesh: boolean;
  45331. /**
  45332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45333. */
  45334. snapDistance: number;
  45335. /**
  45336. * Ratio for the scale of the gizmo (Default: 1)
  45337. */
  45338. scaleRatio: number;
  45339. /**
  45340. * Disposes of the gizmo
  45341. */
  45342. dispose(): void;
  45343. }
  45344. }
  45345. declare module BABYLON {
  45346. /**
  45347. * Single axis scale gizmo
  45348. */
  45349. export class AxisScaleGizmo extends Gizmo {
  45350. /**
  45351. * Drag behavior responsible for the gizmos dragging interactions
  45352. */
  45353. dragBehavior: PointerDragBehavior;
  45354. private _pointerObserver;
  45355. /**
  45356. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45357. */
  45358. snapDistance: number;
  45359. /**
  45360. * Event that fires each time the gizmo snaps to a new location.
  45361. * * snapDistance is the the change in distance
  45362. */
  45363. onSnapObservable: Observable<{
  45364. snapDistance: number;
  45365. }>;
  45366. /**
  45367. * If the scaling operation should be done on all axis (default: false)
  45368. */
  45369. uniformScaling: boolean;
  45370. private _isEnabled;
  45371. private _parent;
  45372. private _arrow;
  45373. private _coloredMaterial;
  45374. private _hoverMaterial;
  45375. /**
  45376. * Creates an AxisScaleGizmo
  45377. * @param gizmoLayer The utility layer the gizmo will be added to
  45378. * @param dragAxis The axis which the gizmo will be able to scale on
  45379. * @param color The color of the gizmo
  45380. */
  45381. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45382. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45383. /**
  45384. * If the gizmo is enabled
  45385. */
  45386. isEnabled: boolean;
  45387. /**
  45388. * Disposes of the gizmo
  45389. */
  45390. dispose(): void;
  45391. /**
  45392. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45393. * @param mesh The mesh to replace the default mesh of the gizmo
  45394. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45395. */
  45396. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45397. }
  45398. }
  45399. declare module BABYLON {
  45400. /**
  45401. * Bounding box gizmo
  45402. */
  45403. export class BoundingBoxGizmo extends Gizmo {
  45404. private _lineBoundingBox;
  45405. private _rotateSpheresParent;
  45406. private _scaleBoxesParent;
  45407. private _boundingDimensions;
  45408. private _renderObserver;
  45409. private _pointerObserver;
  45410. private _scaleDragSpeed;
  45411. private _tmpQuaternion;
  45412. private _tmpVector;
  45413. private _tmpRotationMatrix;
  45414. /**
  45415. * 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)
  45416. */
  45417. ignoreChildren: boolean;
  45418. /**
  45419. * 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)
  45420. */
  45421. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45422. /**
  45423. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45424. */
  45425. rotationSphereSize: number;
  45426. /**
  45427. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45428. */
  45429. scaleBoxSize: number;
  45430. /**
  45431. * 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)
  45432. */
  45433. fixedDragMeshScreenSize: boolean;
  45434. /**
  45435. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45436. */
  45437. fixedDragMeshScreenSizeDistanceFactor: number;
  45438. /**
  45439. * Fired when a rotation sphere or scale box is dragged
  45440. */
  45441. onDragStartObservable: Observable<{}>;
  45442. /**
  45443. * Fired when a scale box is dragged
  45444. */
  45445. onScaleBoxDragObservable: Observable<{}>;
  45446. /**
  45447. * Fired when a scale box drag is ended
  45448. */
  45449. onScaleBoxDragEndObservable: Observable<{}>;
  45450. /**
  45451. * Fired when a rotation sphere is dragged
  45452. */
  45453. onRotationSphereDragObservable: Observable<{}>;
  45454. /**
  45455. * Fired when a rotation sphere drag is ended
  45456. */
  45457. onRotationSphereDragEndObservable: Observable<{}>;
  45458. /**
  45459. * 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)
  45460. */
  45461. scalePivot: Nullable<Vector3>;
  45462. /**
  45463. * Mesh used as a pivot to rotate the attached mesh
  45464. */
  45465. private _anchorMesh;
  45466. private _existingMeshScale;
  45467. private _dragMesh;
  45468. private pointerDragBehavior;
  45469. private coloredMaterial;
  45470. private hoverColoredMaterial;
  45471. /**
  45472. * Sets the color of the bounding box gizmo
  45473. * @param color the color to set
  45474. */
  45475. setColor(color: Color3): void;
  45476. /**
  45477. * Creates an BoundingBoxGizmo
  45478. * @param gizmoLayer The utility layer the gizmo will be added to
  45479. * @param color The color of the gizmo
  45480. */
  45481. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45482. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45483. private _selectNode;
  45484. /**
  45485. * Updates the bounding box information for the Gizmo
  45486. */
  45487. updateBoundingBox(): void;
  45488. private _updateRotationSpheres;
  45489. private _updateScaleBoxes;
  45490. /**
  45491. * Enables rotation on the specified axis and disables rotation on the others
  45492. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45493. */
  45494. setEnabledRotationAxis(axis: string): void;
  45495. /**
  45496. * Enables/disables scaling
  45497. * @param enable if scaling should be enabled
  45498. */
  45499. setEnabledScaling(enable: boolean): void;
  45500. private _updateDummy;
  45501. /**
  45502. * Enables a pointer drag behavior on the bounding box of the gizmo
  45503. */
  45504. enableDragBehavior(): void;
  45505. /**
  45506. * Disposes of the gizmo
  45507. */
  45508. dispose(): void;
  45509. /**
  45510. * 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)
  45511. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45512. * @returns the bounding box mesh with the passed in mesh as a child
  45513. */
  45514. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45515. /**
  45516. * CustomMeshes are not supported by this gizmo
  45517. * @param mesh The mesh to replace the default mesh of the gizmo
  45518. */
  45519. setCustomMesh(mesh: Mesh): void;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * Single plane rotation gizmo
  45525. */
  45526. export class PlaneRotationGizmo extends Gizmo {
  45527. /**
  45528. * Drag behavior responsible for the gizmos dragging interactions
  45529. */
  45530. dragBehavior: PointerDragBehavior;
  45531. private _pointerObserver;
  45532. /**
  45533. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45534. */
  45535. snapDistance: number;
  45536. /**
  45537. * Event that fires each time the gizmo snaps to a new location.
  45538. * * snapDistance is the the change in distance
  45539. */
  45540. onSnapObservable: Observable<{
  45541. snapDistance: number;
  45542. }>;
  45543. private _isEnabled;
  45544. private _parent;
  45545. /**
  45546. * Creates a PlaneRotationGizmo
  45547. * @param gizmoLayer The utility layer the gizmo will be added to
  45548. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45549. * @param color The color of the gizmo
  45550. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45551. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45552. */
  45553. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45554. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45555. /**
  45556. * If the gizmo is enabled
  45557. */
  45558. isEnabled: boolean;
  45559. /**
  45560. * Disposes of the gizmo
  45561. */
  45562. dispose(): void;
  45563. }
  45564. }
  45565. declare module BABYLON {
  45566. /**
  45567. * Gizmo that enables rotating a mesh along 3 axis
  45568. */
  45569. export class RotationGizmo extends Gizmo {
  45570. /**
  45571. * Internal gizmo used for interactions on the x axis
  45572. */
  45573. xGizmo: PlaneRotationGizmo;
  45574. /**
  45575. * Internal gizmo used for interactions on the y axis
  45576. */
  45577. yGizmo: PlaneRotationGizmo;
  45578. /**
  45579. * Internal gizmo used for interactions on the z axis
  45580. */
  45581. zGizmo: PlaneRotationGizmo;
  45582. /** Fires an event when any of it's sub gizmos are dragged */
  45583. onDragStartObservable: Observable<unknown>;
  45584. /** Fires an event when any of it's sub gizmos are released from dragging */
  45585. onDragEndObservable: Observable<unknown>;
  45586. private _meshAttached;
  45587. attachedMesh: Nullable<AbstractMesh>;
  45588. /**
  45589. * Creates a RotationGizmo
  45590. * @param gizmoLayer The utility layer the gizmo will be added to
  45591. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45592. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45593. */
  45594. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45595. updateGizmoRotationToMatchAttachedMesh: boolean;
  45596. /**
  45597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45598. */
  45599. snapDistance: number;
  45600. /**
  45601. * Ratio for the scale of the gizmo (Default: 1)
  45602. */
  45603. scaleRatio: number;
  45604. /**
  45605. * Disposes of the gizmo
  45606. */
  45607. dispose(): void;
  45608. /**
  45609. * CustomMeshes are not supported by this gizmo
  45610. * @param mesh The mesh to replace the default mesh of the gizmo
  45611. */
  45612. setCustomMesh(mesh: Mesh): void;
  45613. }
  45614. }
  45615. declare module BABYLON {
  45616. /**
  45617. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45618. */
  45619. export class GizmoManager implements IDisposable {
  45620. private scene;
  45621. /**
  45622. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45623. */
  45624. gizmos: {
  45625. positionGizmo: Nullable<PositionGizmo>;
  45626. rotationGizmo: Nullable<RotationGizmo>;
  45627. scaleGizmo: Nullable<ScaleGizmo>;
  45628. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45629. };
  45630. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45631. clearGizmoOnEmptyPointerEvent: boolean;
  45632. /** Fires an event when the manager is attached to a mesh */
  45633. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45634. private _gizmosEnabled;
  45635. private _pointerObserver;
  45636. private _attachedMesh;
  45637. private _boundingBoxColor;
  45638. private _defaultUtilityLayer;
  45639. private _defaultKeepDepthUtilityLayer;
  45640. /**
  45641. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45642. */
  45643. boundingBoxDragBehavior: SixDofDragBehavior;
  45644. /**
  45645. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45646. */
  45647. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45648. /**
  45649. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45650. */
  45651. usePointerToAttachGizmos: boolean;
  45652. /**
  45653. * Utility layer that the bounding box gizmo belongs to
  45654. */
  45655. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45656. /**
  45657. * Utility layer that all gizmos besides bounding box belong to
  45658. */
  45659. readonly utilityLayer: UtilityLayerRenderer;
  45660. /**
  45661. * Instatiates a gizmo manager
  45662. * @param scene the scene to overlay the gizmos on top of
  45663. */
  45664. constructor(scene: Scene);
  45665. /**
  45666. * Attaches a set of gizmos to the specified mesh
  45667. * @param mesh The mesh the gizmo's should be attached to
  45668. */
  45669. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45670. /**
  45671. * If the position gizmo is enabled
  45672. */
  45673. positionGizmoEnabled: boolean;
  45674. /**
  45675. * If the rotation gizmo is enabled
  45676. */
  45677. rotationGizmoEnabled: boolean;
  45678. /**
  45679. * If the scale gizmo is enabled
  45680. */
  45681. scaleGizmoEnabled: boolean;
  45682. /**
  45683. * If the boundingBox gizmo is enabled
  45684. */
  45685. boundingBoxGizmoEnabled: boolean;
  45686. /**
  45687. * Disposes of the gizmo manager
  45688. */
  45689. dispose(): void;
  45690. }
  45691. }
  45692. declare module BABYLON {
  45693. /**
  45694. * A directional light is defined by a direction (what a surprise!).
  45695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45696. * 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.
  45697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45698. */
  45699. export class DirectionalLight extends ShadowLight {
  45700. private _shadowFrustumSize;
  45701. /**
  45702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45703. */
  45704. /**
  45705. * Specifies a fix frustum size for the shadow generation.
  45706. */
  45707. shadowFrustumSize: number;
  45708. private _shadowOrthoScale;
  45709. /**
  45710. * Gets the shadow projection scale against the optimal computed one.
  45711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45713. */
  45714. /**
  45715. * Sets the shadow projection scale against the optimal computed one.
  45716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45718. */
  45719. shadowOrthoScale: number;
  45720. /**
  45721. * Automatically compute the projection matrix to best fit (including all the casters)
  45722. * on each frame.
  45723. */
  45724. autoUpdateExtends: boolean;
  45725. private _orthoLeft;
  45726. private _orthoRight;
  45727. private _orthoTop;
  45728. private _orthoBottom;
  45729. /**
  45730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45731. * The directional light is emitted from everywhere in the given direction.
  45732. * It can cast shadows.
  45733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45734. * @param name The friendly name of the light
  45735. * @param direction The direction of the light
  45736. * @param scene The scene the light belongs to
  45737. */
  45738. constructor(name: string, direction: Vector3, scene: Scene);
  45739. /**
  45740. * Returns the string "DirectionalLight".
  45741. * @return The class name
  45742. */
  45743. getClassName(): string;
  45744. /**
  45745. * Returns the integer 1.
  45746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45747. */
  45748. getTypeID(): number;
  45749. /**
  45750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45751. * Returns the DirectionalLight Shadow projection matrix.
  45752. */
  45753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45754. /**
  45755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45756. * Returns the DirectionalLight Shadow projection matrix.
  45757. */
  45758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45759. /**
  45760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45761. * Returns the DirectionalLight Shadow projection matrix.
  45762. */
  45763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45764. protected _buildUniformLayout(): void;
  45765. /**
  45766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45767. * @param effect The effect to update
  45768. * @param lightIndex The index of the light in the effect to update
  45769. * @returns The directional light
  45770. */
  45771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45773. /**
  45774. * Gets the minZ used for shadow according to both the scene and the light.
  45775. *
  45776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45778. * @param activeCamera The camera we are returning the min for
  45779. * @returns the depth min z
  45780. */
  45781. getDepthMinZ(activeCamera: Camera): number;
  45782. /**
  45783. * Gets the maxZ used for shadow according to both the scene and the light.
  45784. *
  45785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45787. * @param activeCamera The camera we are returning the max for
  45788. * @returns the depth max z
  45789. */
  45790. getDepthMaxZ(activeCamera: Camera): number;
  45791. /**
  45792. * Prepares the list of defines specific to the light type.
  45793. * @param defines the list of defines
  45794. * @param lightIndex defines the index of the light for the effect
  45795. */
  45796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45797. }
  45798. }
  45799. declare module BABYLON {
  45800. /**
  45801. * Class containing static functions to help procedurally build meshes
  45802. */
  45803. export class HemisphereBuilder {
  45804. /**
  45805. * Creates a hemisphere mesh
  45806. * @param name defines the name of the mesh
  45807. * @param options defines the options used to create the mesh
  45808. * @param scene defines the hosting scene
  45809. * @returns the hemisphere mesh
  45810. */
  45811. static CreateHemisphere(name: string, options: {
  45812. segments?: number;
  45813. diameter?: number;
  45814. sideOrientation?: number;
  45815. }, scene: any): Mesh;
  45816. }
  45817. }
  45818. declare module BABYLON {
  45819. /**
  45820. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45821. * These values define a cone of light starting from the position, emitting toward the direction.
  45822. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45823. * and the exponent defines the speed of the decay of the light with distance (reach).
  45824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45825. */
  45826. export class SpotLight extends ShadowLight {
  45827. private _angle;
  45828. private _innerAngle;
  45829. private _cosHalfAngle;
  45830. private _lightAngleScale;
  45831. private _lightAngleOffset;
  45832. /**
  45833. * Gets the cone angle of the spot light in Radians.
  45834. */
  45835. /**
  45836. * Sets the cone angle of the spot light in Radians.
  45837. */
  45838. angle: number;
  45839. /**
  45840. * Only used in gltf falloff mode, this defines the angle where
  45841. * the directional falloff will start before cutting at angle which could be seen
  45842. * as outer angle.
  45843. */
  45844. /**
  45845. * Only used in gltf falloff mode, this defines the angle where
  45846. * the directional falloff will start before cutting at angle which could be seen
  45847. * as outer angle.
  45848. */
  45849. innerAngle: number;
  45850. private _shadowAngleScale;
  45851. /**
  45852. * Allows scaling the angle of the light for shadow generation only.
  45853. */
  45854. /**
  45855. * Allows scaling the angle of the light for shadow generation only.
  45856. */
  45857. shadowAngleScale: number;
  45858. /**
  45859. * The light decay speed with the distance from the emission spot.
  45860. */
  45861. exponent: number;
  45862. private _projectionTextureMatrix;
  45863. /**
  45864. * Allows reading the projecton texture
  45865. */
  45866. readonly projectionTextureMatrix: Matrix;
  45867. protected _projectionTextureLightNear: number;
  45868. /**
  45869. * Gets the near clip of the Spotlight for texture projection.
  45870. */
  45871. /**
  45872. * Sets the near clip of the Spotlight for texture projection.
  45873. */
  45874. projectionTextureLightNear: number;
  45875. protected _projectionTextureLightFar: number;
  45876. /**
  45877. * Gets the far clip of the Spotlight for texture projection.
  45878. */
  45879. /**
  45880. * Sets the far clip of the Spotlight for texture projection.
  45881. */
  45882. projectionTextureLightFar: number;
  45883. protected _projectionTextureUpDirection: Vector3;
  45884. /**
  45885. * Gets the Up vector of the Spotlight for texture projection.
  45886. */
  45887. /**
  45888. * Sets the Up vector of the Spotlight for texture projection.
  45889. */
  45890. projectionTextureUpDirection: Vector3;
  45891. private _projectionTexture;
  45892. /**
  45893. * Gets the projection texture of the light.
  45894. */
  45895. /**
  45896. * Sets the projection texture of the light.
  45897. */
  45898. projectionTexture: Nullable<BaseTexture>;
  45899. private _projectionTextureViewLightDirty;
  45900. private _projectionTextureProjectionLightDirty;
  45901. private _projectionTextureDirty;
  45902. private _projectionTextureViewTargetVector;
  45903. private _projectionTextureViewLightMatrix;
  45904. private _projectionTextureProjectionLightMatrix;
  45905. private _projectionTextureScalingMatrix;
  45906. /**
  45907. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45908. * It can cast shadows.
  45909. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45910. * @param name The light friendly name
  45911. * @param position The position of the spot light in the scene
  45912. * @param direction The direction of the light in the scene
  45913. * @param angle The cone angle of the light in Radians
  45914. * @param exponent The light decay speed with the distance from the emission spot
  45915. * @param scene The scene the lights belongs to
  45916. */
  45917. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45918. /**
  45919. * Returns the string "SpotLight".
  45920. * @returns the class name
  45921. */
  45922. getClassName(): string;
  45923. /**
  45924. * Returns the integer 2.
  45925. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45926. */
  45927. getTypeID(): number;
  45928. /**
  45929. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45930. */
  45931. protected _setDirection(value: Vector3): void;
  45932. /**
  45933. * Overrides the position setter to recompute the projection texture view light Matrix.
  45934. */
  45935. protected _setPosition(value: Vector3): void;
  45936. /**
  45937. * 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.
  45938. * Returns the SpotLight.
  45939. */
  45940. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45941. protected _computeProjectionTextureViewLightMatrix(): void;
  45942. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45943. /**
  45944. * Main function for light texture projection matrix computing.
  45945. */
  45946. protected _computeProjectionTextureMatrix(): void;
  45947. protected _buildUniformLayout(): void;
  45948. private _computeAngleValues;
  45949. /**
  45950. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45951. * @param effect The effect to update
  45952. * @param lightIndex The index of the light in the effect to update
  45953. * @returns The spot light
  45954. */
  45955. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45956. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45957. /**
  45958. * Disposes the light and the associated resources.
  45959. */
  45960. dispose(): void;
  45961. /**
  45962. * Prepares the list of defines specific to the light type.
  45963. * @param defines the list of defines
  45964. * @param lightIndex defines the index of the light for the effect
  45965. */
  45966. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45967. }
  45968. }
  45969. declare module BABYLON {
  45970. /**
  45971. * Gizmo that enables viewing a light
  45972. */
  45973. export class LightGizmo extends Gizmo {
  45974. private _lightMesh;
  45975. private _material;
  45976. private cachedPosition;
  45977. private cachedForward;
  45978. /**
  45979. * Creates a LightGizmo
  45980. * @param gizmoLayer The utility layer the gizmo will be added to
  45981. */
  45982. constructor(gizmoLayer?: UtilityLayerRenderer);
  45983. private _light;
  45984. /**
  45985. * The light that the gizmo is attached to
  45986. */
  45987. light: Nullable<Light>;
  45988. /**
  45989. * Gets the material used to render the light gizmo
  45990. */
  45991. readonly material: StandardMaterial;
  45992. /**
  45993. * @hidden
  45994. * Updates the gizmo to match the attached mesh's position/rotation
  45995. */
  45996. protected _update(): void;
  45997. private static _Scale;
  45998. /**
  45999. * Creates the lines for a light mesh
  46000. */
  46001. private static _createLightLines;
  46002. /**
  46003. * Disposes of the light gizmo
  46004. */
  46005. dispose(): void;
  46006. private static _CreateHemisphericLightMesh;
  46007. private static _CreatePointLightMesh;
  46008. private static _CreateSpotLightMesh;
  46009. private static _CreateDirectionalLightMesh;
  46010. }
  46011. }
  46012. declare module BABYLON {
  46013. /** @hidden */
  46014. export var backgroundFragmentDeclaration: {
  46015. name: string;
  46016. shader: string;
  46017. };
  46018. }
  46019. declare module BABYLON {
  46020. /** @hidden */
  46021. export var backgroundUboDeclaration: {
  46022. name: string;
  46023. shader: string;
  46024. };
  46025. }
  46026. declare module BABYLON {
  46027. /** @hidden */
  46028. export var backgroundPixelShader: {
  46029. name: string;
  46030. shader: string;
  46031. };
  46032. }
  46033. declare module BABYLON {
  46034. /** @hidden */
  46035. export var backgroundVertexDeclaration: {
  46036. name: string;
  46037. shader: string;
  46038. };
  46039. }
  46040. declare module BABYLON {
  46041. /** @hidden */
  46042. export var backgroundVertexShader: {
  46043. name: string;
  46044. shader: string;
  46045. };
  46046. }
  46047. declare module BABYLON {
  46048. /**
  46049. * Background material used to create an efficient environement around your scene.
  46050. */
  46051. export class BackgroundMaterial extends PushMaterial {
  46052. /**
  46053. * Standard reflectance value at parallel view angle.
  46054. */
  46055. static StandardReflectance0: number;
  46056. /**
  46057. * Standard reflectance value at grazing angle.
  46058. */
  46059. static StandardReflectance90: number;
  46060. protected _primaryColor: Color3;
  46061. /**
  46062. * Key light Color (multiply against the environement texture)
  46063. */
  46064. primaryColor: Color3;
  46065. protected __perceptualColor: Nullable<Color3>;
  46066. /**
  46067. * Experimental Internal Use Only.
  46068. *
  46069. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46070. * This acts as a helper to set the primary color to a more "human friendly" value.
  46071. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46072. * output color as close as possible from the chosen value.
  46073. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46074. * part of lighting setup.)
  46075. */
  46076. _perceptualColor: Nullable<Color3>;
  46077. protected _primaryColorShadowLevel: float;
  46078. /**
  46079. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46080. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46081. */
  46082. primaryColorShadowLevel: float;
  46083. protected _primaryColorHighlightLevel: float;
  46084. /**
  46085. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46086. * The primary color is used at the level chosen to define what the white area would look.
  46087. */
  46088. primaryColorHighlightLevel: float;
  46089. protected _reflectionTexture: Nullable<BaseTexture>;
  46090. /**
  46091. * Reflection Texture used in the material.
  46092. * Should be author in a specific way for the best result (refer to the documentation).
  46093. */
  46094. reflectionTexture: Nullable<BaseTexture>;
  46095. protected _reflectionBlur: float;
  46096. /**
  46097. * Reflection Texture level of blur.
  46098. *
  46099. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46100. * texture twice.
  46101. */
  46102. reflectionBlur: float;
  46103. protected _diffuseTexture: Nullable<BaseTexture>;
  46104. /**
  46105. * Diffuse Texture used in the material.
  46106. * Should be author in a specific way for the best result (refer to the documentation).
  46107. */
  46108. diffuseTexture: Nullable<BaseTexture>;
  46109. protected _shadowLights: Nullable<IShadowLight[]>;
  46110. /**
  46111. * Specify the list of lights casting shadow on the material.
  46112. * All scene shadow lights will be included if null.
  46113. */
  46114. shadowLights: Nullable<IShadowLight[]>;
  46115. protected _shadowLevel: float;
  46116. /**
  46117. * Helps adjusting the shadow to a softer level if required.
  46118. * 0 means black shadows and 1 means no shadows.
  46119. */
  46120. shadowLevel: float;
  46121. protected _sceneCenter: Vector3;
  46122. /**
  46123. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46124. * It is usually zero but might be interesting to modify according to your setup.
  46125. */
  46126. sceneCenter: Vector3;
  46127. protected _opacityFresnel: boolean;
  46128. /**
  46129. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46130. * This helps ensuring a nice transition when the camera goes under the ground.
  46131. */
  46132. opacityFresnel: boolean;
  46133. protected _reflectionFresnel: boolean;
  46134. /**
  46135. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46136. * This helps adding a mirror texture on the ground.
  46137. */
  46138. reflectionFresnel: boolean;
  46139. protected _reflectionFalloffDistance: number;
  46140. /**
  46141. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46142. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46143. */
  46144. reflectionFalloffDistance: number;
  46145. protected _reflectionAmount: number;
  46146. /**
  46147. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46148. */
  46149. reflectionAmount: number;
  46150. protected _reflectionReflectance0: number;
  46151. /**
  46152. * This specifies the weight of the reflection at grazing angle.
  46153. */
  46154. reflectionReflectance0: number;
  46155. protected _reflectionReflectance90: number;
  46156. /**
  46157. * This specifies the weight of the reflection at a perpendicular point of view.
  46158. */
  46159. reflectionReflectance90: number;
  46160. /**
  46161. * Sets the reflection reflectance fresnel values according to the default standard
  46162. * empirically know to work well :-)
  46163. */
  46164. reflectionStandardFresnelWeight: number;
  46165. protected _useRGBColor: boolean;
  46166. /**
  46167. * Helps to directly use the maps channels instead of their level.
  46168. */
  46169. useRGBColor: boolean;
  46170. protected _enableNoise: boolean;
  46171. /**
  46172. * This helps reducing the banding effect that could occur on the background.
  46173. */
  46174. enableNoise: boolean;
  46175. /**
  46176. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46177. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46178. * Recommended to be keep at 1.0 except for special cases.
  46179. */
  46180. fovMultiplier: number;
  46181. private _fovMultiplier;
  46182. /**
  46183. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46184. */
  46185. useEquirectangularFOV: boolean;
  46186. private _maxSimultaneousLights;
  46187. /**
  46188. * Number of Simultaneous lights allowed on the material.
  46189. */
  46190. maxSimultaneousLights: int;
  46191. /**
  46192. * Default configuration related to image processing available in the Background Material.
  46193. */
  46194. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46195. /**
  46196. * Keep track of the image processing observer to allow dispose and replace.
  46197. */
  46198. private _imageProcessingObserver;
  46199. /**
  46200. * Attaches a new image processing configuration to the PBR Material.
  46201. * @param configuration (if null the scene configuration will be use)
  46202. */
  46203. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46204. /**
  46205. * Gets the image processing configuration used either in this material.
  46206. */
  46207. /**
  46208. * Sets the Default image processing configuration used either in the this material.
  46209. *
  46210. * If sets to null, the scene one is in use.
  46211. */
  46212. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46213. /**
  46214. * Gets wether the color curves effect is enabled.
  46215. */
  46216. /**
  46217. * Sets wether the color curves effect is enabled.
  46218. */
  46219. cameraColorCurvesEnabled: boolean;
  46220. /**
  46221. * Gets wether the color grading effect is enabled.
  46222. */
  46223. /**
  46224. * Gets wether the color grading effect is enabled.
  46225. */
  46226. cameraColorGradingEnabled: boolean;
  46227. /**
  46228. * Gets wether tonemapping is enabled or not.
  46229. */
  46230. /**
  46231. * Sets wether tonemapping is enabled or not
  46232. */
  46233. cameraToneMappingEnabled: boolean;
  46234. /**
  46235. * The camera exposure used on this material.
  46236. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46237. * This corresponds to a photographic exposure.
  46238. */
  46239. /**
  46240. * The camera exposure used on this material.
  46241. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46242. * This corresponds to a photographic exposure.
  46243. */
  46244. cameraExposure: float;
  46245. /**
  46246. * Gets The camera contrast used on this material.
  46247. */
  46248. /**
  46249. * Sets The camera contrast used on this material.
  46250. */
  46251. cameraContrast: float;
  46252. /**
  46253. * Gets the Color Grading 2D Lookup Texture.
  46254. */
  46255. /**
  46256. * Sets the Color Grading 2D Lookup Texture.
  46257. */
  46258. cameraColorGradingTexture: Nullable<BaseTexture>;
  46259. /**
  46260. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46261. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46262. * 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;
  46263. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46264. */
  46265. /**
  46266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46268. * 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;
  46269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46270. */
  46271. cameraColorCurves: Nullable<ColorCurves>;
  46272. /**
  46273. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46274. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46275. */
  46276. switchToBGR: boolean;
  46277. private _renderTargets;
  46278. private _reflectionControls;
  46279. private _white;
  46280. private _primaryShadowColor;
  46281. private _primaryHighlightColor;
  46282. /**
  46283. * Instantiates a Background Material in the given scene
  46284. * @param name The friendly name of the material
  46285. * @param scene The scene to add the material to
  46286. */
  46287. constructor(name: string, scene: Scene);
  46288. /**
  46289. * Gets a boolean indicating that current material needs to register RTT
  46290. */
  46291. readonly hasRenderTargetTextures: boolean;
  46292. /**
  46293. * The entire material has been created in order to prevent overdraw.
  46294. * @returns false
  46295. */
  46296. needAlphaTesting(): boolean;
  46297. /**
  46298. * The entire material has been created in order to prevent overdraw.
  46299. * @returns true if blending is enable
  46300. */
  46301. needAlphaBlending(): boolean;
  46302. /**
  46303. * Checks wether the material is ready to be rendered for a given mesh.
  46304. * @param mesh The mesh to render
  46305. * @param subMesh The submesh to check against
  46306. * @param useInstances Specify wether or not the material is used with instances
  46307. * @returns true if all the dependencies are ready (Textures, Effects...)
  46308. */
  46309. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46310. /**
  46311. * Compute the primary color according to the chosen perceptual color.
  46312. */
  46313. private _computePrimaryColorFromPerceptualColor;
  46314. /**
  46315. * Compute the highlights and shadow colors according to their chosen levels.
  46316. */
  46317. private _computePrimaryColors;
  46318. /**
  46319. * Build the uniform buffer used in the material.
  46320. */
  46321. buildUniformLayout(): void;
  46322. /**
  46323. * Unbind the material.
  46324. */
  46325. unbind(): void;
  46326. /**
  46327. * Bind only the world matrix to the material.
  46328. * @param world The world matrix to bind.
  46329. */
  46330. bindOnlyWorldMatrix(world: Matrix): void;
  46331. /**
  46332. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46333. * @param world The world matrix to bind.
  46334. * @param subMesh The submesh to bind for.
  46335. */
  46336. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46337. /**
  46338. * Checks to see if a texture is used in the material.
  46339. * @param texture - Base texture to use.
  46340. * @returns - Boolean specifying if a texture is used in the material.
  46341. */
  46342. hasTexture(texture: BaseTexture): boolean;
  46343. /**
  46344. * Dispose the material.
  46345. * @param forceDisposeEffect Force disposal of the associated effect.
  46346. * @param forceDisposeTextures Force disposal of the associated textures.
  46347. */
  46348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46349. /**
  46350. * Clones the material.
  46351. * @param name The cloned name.
  46352. * @returns The cloned material.
  46353. */
  46354. clone(name: string): BackgroundMaterial;
  46355. /**
  46356. * Serializes the current material to its JSON representation.
  46357. * @returns The JSON representation.
  46358. */
  46359. serialize(): any;
  46360. /**
  46361. * Gets the class name of the material
  46362. * @returns "BackgroundMaterial"
  46363. */
  46364. getClassName(): string;
  46365. /**
  46366. * Parse a JSON input to create back a background material.
  46367. * @param source The JSON data to parse
  46368. * @param scene The scene to create the parsed material in
  46369. * @param rootUrl The root url of the assets the material depends upon
  46370. * @returns the instantiated BackgroundMaterial.
  46371. */
  46372. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * Represents the different options available during the creation of
  46378. * a Environment helper.
  46379. *
  46380. * This can control the default ground, skybox and image processing setup of your scene.
  46381. */
  46382. export interface IEnvironmentHelperOptions {
  46383. /**
  46384. * Specifies wether or not to create a ground.
  46385. * True by default.
  46386. */
  46387. createGround: boolean;
  46388. /**
  46389. * Specifies the ground size.
  46390. * 15 by default.
  46391. */
  46392. groundSize: number;
  46393. /**
  46394. * The texture used on the ground for the main color.
  46395. * Comes from the BabylonJS CDN by default.
  46396. *
  46397. * Remarks: Can be either a texture or a url.
  46398. */
  46399. groundTexture: string | BaseTexture;
  46400. /**
  46401. * The color mixed in the ground texture by default.
  46402. * BabylonJS clearColor by default.
  46403. */
  46404. groundColor: Color3;
  46405. /**
  46406. * Specifies the ground opacity.
  46407. * 1 by default.
  46408. */
  46409. groundOpacity: number;
  46410. /**
  46411. * Enables the ground to receive shadows.
  46412. * True by default.
  46413. */
  46414. enableGroundShadow: boolean;
  46415. /**
  46416. * Helps preventing the shadow to be fully black on the ground.
  46417. * 0.5 by default.
  46418. */
  46419. groundShadowLevel: number;
  46420. /**
  46421. * Creates a mirror texture attach to the ground.
  46422. * false by default.
  46423. */
  46424. enableGroundMirror: boolean;
  46425. /**
  46426. * Specifies the ground mirror size ratio.
  46427. * 0.3 by default as the default kernel is 64.
  46428. */
  46429. groundMirrorSizeRatio: number;
  46430. /**
  46431. * Specifies the ground mirror blur kernel size.
  46432. * 64 by default.
  46433. */
  46434. groundMirrorBlurKernel: number;
  46435. /**
  46436. * Specifies the ground mirror visibility amount.
  46437. * 1 by default
  46438. */
  46439. groundMirrorAmount: number;
  46440. /**
  46441. * Specifies the ground mirror reflectance weight.
  46442. * This uses the standard weight of the background material to setup the fresnel effect
  46443. * of the mirror.
  46444. * 1 by default.
  46445. */
  46446. groundMirrorFresnelWeight: number;
  46447. /**
  46448. * Specifies the ground mirror Falloff distance.
  46449. * This can helps reducing the size of the reflection.
  46450. * 0 by Default.
  46451. */
  46452. groundMirrorFallOffDistance: number;
  46453. /**
  46454. * Specifies the ground mirror texture type.
  46455. * Unsigned Int by Default.
  46456. */
  46457. groundMirrorTextureType: number;
  46458. /**
  46459. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46460. * the shown objects.
  46461. */
  46462. groundYBias: number;
  46463. /**
  46464. * Specifies wether or not to create a skybox.
  46465. * True by default.
  46466. */
  46467. createSkybox: boolean;
  46468. /**
  46469. * Specifies the skybox size.
  46470. * 20 by default.
  46471. */
  46472. skyboxSize: number;
  46473. /**
  46474. * The texture used on the skybox for the main color.
  46475. * Comes from the BabylonJS CDN by default.
  46476. *
  46477. * Remarks: Can be either a texture or a url.
  46478. */
  46479. skyboxTexture: string | BaseTexture;
  46480. /**
  46481. * The color mixed in the skybox texture by default.
  46482. * BabylonJS clearColor by default.
  46483. */
  46484. skyboxColor: Color3;
  46485. /**
  46486. * The background rotation around the Y axis of the scene.
  46487. * This helps aligning the key lights of your scene with the background.
  46488. * 0 by default.
  46489. */
  46490. backgroundYRotation: number;
  46491. /**
  46492. * Compute automatically the size of the elements to best fit with the scene.
  46493. */
  46494. sizeAuto: boolean;
  46495. /**
  46496. * Default position of the rootMesh if autoSize is not true.
  46497. */
  46498. rootPosition: Vector3;
  46499. /**
  46500. * Sets up the image processing in the scene.
  46501. * true by default.
  46502. */
  46503. setupImageProcessing: boolean;
  46504. /**
  46505. * The texture used as your environment texture in the scene.
  46506. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46507. *
  46508. * Remarks: Can be either a texture or a url.
  46509. */
  46510. environmentTexture: string | BaseTexture;
  46511. /**
  46512. * The value of the exposure to apply to the scene.
  46513. * 0.6 by default if setupImageProcessing is true.
  46514. */
  46515. cameraExposure: number;
  46516. /**
  46517. * The value of the contrast to apply to the scene.
  46518. * 1.6 by default if setupImageProcessing is true.
  46519. */
  46520. cameraContrast: number;
  46521. /**
  46522. * Specifies wether or not tonemapping should be enabled in the scene.
  46523. * true by default if setupImageProcessing is true.
  46524. */
  46525. toneMappingEnabled: boolean;
  46526. }
  46527. /**
  46528. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46529. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46530. * It also helps with the default setup of your imageProcessing configuration.
  46531. */
  46532. export class EnvironmentHelper {
  46533. /**
  46534. * Default ground texture URL.
  46535. */
  46536. private static _groundTextureCDNUrl;
  46537. /**
  46538. * Default skybox texture URL.
  46539. */
  46540. private static _skyboxTextureCDNUrl;
  46541. /**
  46542. * Default environment texture URL.
  46543. */
  46544. private static _environmentTextureCDNUrl;
  46545. /**
  46546. * Creates the default options for the helper.
  46547. */
  46548. private static _getDefaultOptions;
  46549. private _rootMesh;
  46550. /**
  46551. * Gets the root mesh created by the helper.
  46552. */
  46553. readonly rootMesh: Mesh;
  46554. private _skybox;
  46555. /**
  46556. * Gets the skybox created by the helper.
  46557. */
  46558. readonly skybox: Nullable<Mesh>;
  46559. private _skyboxTexture;
  46560. /**
  46561. * Gets the skybox texture created by the helper.
  46562. */
  46563. readonly skyboxTexture: Nullable<BaseTexture>;
  46564. private _skyboxMaterial;
  46565. /**
  46566. * Gets the skybox material created by the helper.
  46567. */
  46568. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46569. private _ground;
  46570. /**
  46571. * Gets the ground mesh created by the helper.
  46572. */
  46573. readonly ground: Nullable<Mesh>;
  46574. private _groundTexture;
  46575. /**
  46576. * Gets the ground texture created by the helper.
  46577. */
  46578. readonly groundTexture: Nullable<BaseTexture>;
  46579. private _groundMirror;
  46580. /**
  46581. * Gets the ground mirror created by the helper.
  46582. */
  46583. readonly groundMirror: Nullable<MirrorTexture>;
  46584. /**
  46585. * Gets the ground mirror render list to helps pushing the meshes
  46586. * you wish in the ground reflection.
  46587. */
  46588. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46589. private _groundMaterial;
  46590. /**
  46591. * Gets the ground material created by the helper.
  46592. */
  46593. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46594. /**
  46595. * Stores the creation options.
  46596. */
  46597. private readonly _scene;
  46598. private _options;
  46599. /**
  46600. * This observable will be notified with any error during the creation of the environment,
  46601. * mainly texture creation errors.
  46602. */
  46603. onErrorObservable: Observable<{
  46604. message?: string;
  46605. exception?: any;
  46606. }>;
  46607. /**
  46608. * constructor
  46609. * @param options Defines the options we want to customize the helper
  46610. * @param scene The scene to add the material to
  46611. */
  46612. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46613. /**
  46614. * Updates the background according to the new options
  46615. * @param options
  46616. */
  46617. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46618. /**
  46619. * Sets the primary color of all the available elements.
  46620. * @param color the main color to affect to the ground and the background
  46621. */
  46622. setMainColor(color: Color3): void;
  46623. /**
  46624. * Setup the image processing according to the specified options.
  46625. */
  46626. private _setupImageProcessing;
  46627. /**
  46628. * Setup the environment texture according to the specified options.
  46629. */
  46630. private _setupEnvironmentTexture;
  46631. /**
  46632. * Setup the background according to the specified options.
  46633. */
  46634. private _setupBackground;
  46635. /**
  46636. * Get the scene sizes according to the setup.
  46637. */
  46638. private _getSceneSize;
  46639. /**
  46640. * Setup the ground according to the specified options.
  46641. */
  46642. private _setupGround;
  46643. /**
  46644. * Setup the ground material according to the specified options.
  46645. */
  46646. private _setupGroundMaterial;
  46647. /**
  46648. * Setup the ground diffuse texture according to the specified options.
  46649. */
  46650. private _setupGroundDiffuseTexture;
  46651. /**
  46652. * Setup the ground mirror texture according to the specified options.
  46653. */
  46654. private _setupGroundMirrorTexture;
  46655. /**
  46656. * Setup the ground to receive the mirror texture.
  46657. */
  46658. private _setupMirrorInGroundMaterial;
  46659. /**
  46660. * Setup the skybox according to the specified options.
  46661. */
  46662. private _setupSkybox;
  46663. /**
  46664. * Setup the skybox material according to the specified options.
  46665. */
  46666. private _setupSkyboxMaterial;
  46667. /**
  46668. * Setup the skybox reflection texture according to the specified options.
  46669. */
  46670. private _setupSkyboxReflectionTexture;
  46671. private _errorHandler;
  46672. /**
  46673. * Dispose all the elements created by the Helper.
  46674. */
  46675. dispose(): void;
  46676. }
  46677. }
  46678. declare module BABYLON {
  46679. /**
  46680. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46681. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46682. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46683. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46684. */
  46685. export class PhotoDome extends TransformNode {
  46686. /**
  46687. * Define the image as a Monoscopic panoramic 360 image.
  46688. */
  46689. static readonly MODE_MONOSCOPIC: number;
  46690. /**
  46691. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46692. */
  46693. static readonly MODE_TOPBOTTOM: number;
  46694. /**
  46695. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46696. */
  46697. static readonly MODE_SIDEBYSIDE: number;
  46698. private _useDirectMapping;
  46699. /**
  46700. * The texture being displayed on the sphere
  46701. */
  46702. protected _photoTexture: Texture;
  46703. /**
  46704. * Gets or sets the texture being displayed on the sphere
  46705. */
  46706. photoTexture: Texture;
  46707. /**
  46708. * Observable raised when an error occured while loading the 360 image
  46709. */
  46710. onLoadErrorObservable: Observable<string>;
  46711. /**
  46712. * The skybox material
  46713. */
  46714. protected _material: BackgroundMaterial;
  46715. /**
  46716. * The surface used for the skybox
  46717. */
  46718. protected _mesh: Mesh;
  46719. /**
  46720. * Gets the mesh used for the skybox.
  46721. */
  46722. readonly mesh: Mesh;
  46723. /**
  46724. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46725. * Also see the options.resolution property.
  46726. */
  46727. fovMultiplier: number;
  46728. private _imageMode;
  46729. /**
  46730. * Gets or set the current video mode for the video. It can be:
  46731. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46732. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46733. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46734. */
  46735. imageMode: number;
  46736. /**
  46737. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46738. * @param name Element's name, child elements will append suffixes for their own names.
  46739. * @param urlsOfPhoto defines the url of the photo to display
  46740. * @param options defines an object containing optional or exposed sub element properties
  46741. * @param onError defines a callback called when an error occured while loading the texture
  46742. */
  46743. constructor(name: string, urlOfPhoto: string, options: {
  46744. resolution?: number;
  46745. size?: number;
  46746. useDirectMapping?: boolean;
  46747. faceForward?: boolean;
  46748. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46749. private _onBeforeCameraRenderObserver;
  46750. private _changeImageMode;
  46751. /**
  46752. * Releases resources associated with this node.
  46753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46755. */
  46756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46757. }
  46758. }
  46759. declare module BABYLON {
  46760. /**
  46761. * Class used to host RGBD texture specific utilities
  46762. */
  46763. export class RGBDTextureTools {
  46764. /**
  46765. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46766. * @param texture the texture to expand.
  46767. */
  46768. static ExpandRGBDTexture(texture: Texture): void;
  46769. }
  46770. }
  46771. declare module BABYLON {
  46772. /**
  46773. * Class used to host texture specific utilities
  46774. */
  46775. export class BRDFTextureTools {
  46776. /**
  46777. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46778. * @param scene defines the hosting scene
  46779. * @returns the environment BRDF texture
  46780. */
  46781. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46782. private static _environmentBRDFBase64Texture;
  46783. }
  46784. }
  46785. declare module BABYLON {
  46786. /**
  46787. * @hidden
  46788. */
  46789. export interface IMaterialClearCoatDefines {
  46790. CLEARCOAT: boolean;
  46791. CLEARCOAT_DEFAULTIOR: boolean;
  46792. CLEARCOAT_TEXTURE: boolean;
  46793. CLEARCOAT_TEXTUREDIRECTUV: number;
  46794. CLEARCOAT_BUMP: boolean;
  46795. CLEARCOAT_BUMPDIRECTUV: number;
  46796. CLEARCOAT_TINT: boolean;
  46797. CLEARCOAT_TINT_TEXTURE: boolean;
  46798. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46799. /** @hidden */
  46800. _areTexturesDirty: boolean;
  46801. }
  46802. /**
  46803. * Define the code related to the clear coat parameters of the pbr material.
  46804. */
  46805. export class PBRClearCoatConfiguration {
  46806. /**
  46807. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46808. * The default fits with a polyurethane material.
  46809. */
  46810. private static readonly _DefaultIndexOfRefraction;
  46811. private _isEnabled;
  46812. /**
  46813. * Defines if the clear coat is enabled in the material.
  46814. */
  46815. isEnabled: boolean;
  46816. /**
  46817. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46818. */
  46819. intensity: number;
  46820. /**
  46821. * Defines the clear coat layer roughness.
  46822. */
  46823. roughness: number;
  46824. private _indexOfRefraction;
  46825. /**
  46826. * Defines the index of refraction of the clear coat.
  46827. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46828. * The default fits with a polyurethane material.
  46829. * Changing the default value is more performance intensive.
  46830. */
  46831. indexOfRefraction: number;
  46832. private _texture;
  46833. /**
  46834. * Stores the clear coat values in a texture.
  46835. */
  46836. texture: Nullable<BaseTexture>;
  46837. private _bumpTexture;
  46838. /**
  46839. * Define the clear coat specific bump texture.
  46840. */
  46841. bumpTexture: Nullable<BaseTexture>;
  46842. private _isTintEnabled;
  46843. /**
  46844. * Defines if the clear coat tint is enabled in the material.
  46845. */
  46846. isTintEnabled: boolean;
  46847. /**
  46848. * Defines the clear coat tint of the material.
  46849. * This is only use if tint is enabled
  46850. */
  46851. tintColor: Color3;
  46852. /**
  46853. * Defines the distance at which the tint color should be found in the
  46854. * clear coat media.
  46855. * This is only use if tint is enabled
  46856. */
  46857. tintColorAtDistance: number;
  46858. /**
  46859. * Defines the clear coat layer thickness.
  46860. * This is only use if tint is enabled
  46861. */
  46862. tintThickness: number;
  46863. private _tintTexture;
  46864. /**
  46865. * Stores the clear tint values in a texture.
  46866. * rgb is tint
  46867. * a is a thickness factor
  46868. */
  46869. tintTexture: Nullable<BaseTexture>;
  46870. /** @hidden */
  46871. private _internalMarkAllSubMeshesAsTexturesDirty;
  46872. /** @hidden */
  46873. _markAllSubMeshesAsTexturesDirty(): void;
  46874. /**
  46875. * Instantiate a new istance of clear coat configuration.
  46876. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46877. */
  46878. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46879. /**
  46880. * Gets wehter the submesh is ready to be used or not.
  46881. * @param defines the list of "defines" to update.
  46882. * @param scene defines the scene the material belongs to.
  46883. * @param engine defines the engine the material belongs to.
  46884. * @param disableBumpMap defines wether the material disables bump or not.
  46885. * @returns - boolean indicating that the submesh is ready or not.
  46886. */
  46887. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46888. /**
  46889. * Checks to see if a texture is used in the material.
  46890. * @param defines the list of "defines" to update.
  46891. * @param scene defines the scene to the material belongs to.
  46892. */
  46893. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46894. /**
  46895. * Binds the material data.
  46896. * @param uniformBuffer defines the Uniform buffer to fill in.
  46897. * @param scene defines the scene the material belongs to.
  46898. * @param engine defines the engine the material belongs to.
  46899. * @param disableBumpMap defines wether the material disables bump or not.
  46900. * @param isFrozen defines wether the material is frozen or not.
  46901. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46902. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46903. */
  46904. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46905. /**
  46906. * Checks to see if a texture is used in the material.
  46907. * @param texture - Base texture to use.
  46908. * @returns - Boolean specifying if a texture is used in the material.
  46909. */
  46910. hasTexture(texture: BaseTexture): boolean;
  46911. /**
  46912. * Returns an array of the actively used textures.
  46913. * @param activeTextures Array of BaseTextures
  46914. */
  46915. getActiveTextures(activeTextures: BaseTexture[]): void;
  46916. /**
  46917. * Returns the animatable textures.
  46918. * @param animatables Array of animatable textures.
  46919. */
  46920. getAnimatables(animatables: IAnimatable[]): void;
  46921. /**
  46922. * Disposes the resources of the material.
  46923. * @param forceDisposeTextures - Forces the disposal of all textures.
  46924. */
  46925. dispose(forceDisposeTextures?: boolean): void;
  46926. /**
  46927. * Get the current class name of the texture useful for serialization or dynamic coding.
  46928. * @returns "PBRClearCoatConfiguration"
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Add fallbacks to the effect fallbacks list.
  46933. * @param defines defines the Base texture to use.
  46934. * @param fallbacks defines the current fallback list.
  46935. * @param currentRank defines the current fallback rank.
  46936. * @returns the new fallback rank.
  46937. */
  46938. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46939. /**
  46940. * Add the required uniforms to the current list.
  46941. * @param uniforms defines the current uniform list.
  46942. */
  46943. static AddUniforms(uniforms: string[]): void;
  46944. /**
  46945. * Add the required samplers to the current list.
  46946. * @param samplers defines the current sampler list.
  46947. */
  46948. static AddSamplers(samplers: string[]): void;
  46949. /**
  46950. * Add the required uniforms to the current buffer.
  46951. * @param uniformBuffer defines the current uniform buffer.
  46952. */
  46953. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46954. /**
  46955. * Makes a duplicate of the current configuration into another one.
  46956. * @param clearCoatConfiguration define the config where to copy the info
  46957. */
  46958. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46959. /**
  46960. * Serializes this clear coat configuration.
  46961. * @returns - An object with the serialized config.
  46962. */
  46963. serialize(): any;
  46964. /**
  46965. * Parses a anisotropy Configuration from a serialized object.
  46966. * @param source - Serialized object.
  46967. * @param scene Defines the scene we are parsing for
  46968. * @param rootUrl Defines the rootUrl to load from
  46969. */
  46970. parse(source: any, scene: Scene, rootUrl: string): void;
  46971. }
  46972. }
  46973. declare module BABYLON {
  46974. /**
  46975. * @hidden
  46976. */
  46977. export interface IMaterialAnisotropicDefines {
  46978. ANISOTROPIC: boolean;
  46979. ANISOTROPIC_TEXTURE: boolean;
  46980. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46981. MAINUV1: boolean;
  46982. _areTexturesDirty: boolean;
  46983. _needUVs: boolean;
  46984. }
  46985. /**
  46986. * Define the code related to the anisotropic parameters of the pbr material.
  46987. */
  46988. export class PBRAnisotropicConfiguration {
  46989. private _isEnabled;
  46990. /**
  46991. * Defines if the anisotropy is enabled in the material.
  46992. */
  46993. isEnabled: boolean;
  46994. /**
  46995. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46996. */
  46997. intensity: number;
  46998. /**
  46999. * Defines if the effect is along the tangents, bitangents or in between.
  47000. * By default, the effect is "strectching" the highlights along the tangents.
  47001. */
  47002. direction: Vector2;
  47003. private _texture;
  47004. /**
  47005. * Stores the anisotropy values in a texture.
  47006. * rg is direction (like normal from -1 to 1)
  47007. * b is a intensity
  47008. */
  47009. texture: Nullable<BaseTexture>;
  47010. /** @hidden */
  47011. private _internalMarkAllSubMeshesAsTexturesDirty;
  47012. /** @hidden */
  47013. _markAllSubMeshesAsTexturesDirty(): void;
  47014. /**
  47015. * Instantiate a new istance of anisotropy configuration.
  47016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47017. */
  47018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47019. /**
  47020. * Specifies that the submesh is ready to be used.
  47021. * @param defines the list of "defines" to update.
  47022. * @param scene defines the scene the material belongs to.
  47023. * @returns - boolean indicating that the submesh is ready or not.
  47024. */
  47025. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47026. /**
  47027. * Checks to see if a texture is used in the material.
  47028. * @param defines the list of "defines" to update.
  47029. * @param mesh the mesh we are preparing the defines for.
  47030. * @param scene defines the scene the material belongs to.
  47031. */
  47032. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47033. /**
  47034. * Binds the material data.
  47035. * @param uniformBuffer defines the Uniform buffer to fill in.
  47036. * @param scene defines the scene the material belongs to.
  47037. * @param isFrozen defines wether the material is frozen or not.
  47038. */
  47039. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47040. /**
  47041. * Checks to see if a texture is used in the material.
  47042. * @param texture - Base texture to use.
  47043. * @returns - Boolean specifying if a texture is used in the material.
  47044. */
  47045. hasTexture(texture: BaseTexture): boolean;
  47046. /**
  47047. * Returns an array of the actively used textures.
  47048. * @param activeTextures Array of BaseTextures
  47049. */
  47050. getActiveTextures(activeTextures: BaseTexture[]): void;
  47051. /**
  47052. * Returns the animatable textures.
  47053. * @param animatables Array of animatable textures.
  47054. */
  47055. getAnimatables(animatables: IAnimatable[]): void;
  47056. /**
  47057. * Disposes the resources of the material.
  47058. * @param forceDisposeTextures - Forces the disposal of all textures.
  47059. */
  47060. dispose(forceDisposeTextures?: boolean): void;
  47061. /**
  47062. * Get the current class name of the texture useful for serialization or dynamic coding.
  47063. * @returns "PBRAnisotropicConfiguration"
  47064. */
  47065. getClassName(): string;
  47066. /**
  47067. * Add fallbacks to the effect fallbacks list.
  47068. * @param defines defines the Base texture to use.
  47069. * @param fallbacks defines the current fallback list.
  47070. * @param currentRank defines the current fallback rank.
  47071. * @returns the new fallback rank.
  47072. */
  47073. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47074. /**
  47075. * Add the required uniforms to the current list.
  47076. * @param uniforms defines the current uniform list.
  47077. */
  47078. static AddUniforms(uniforms: string[]): void;
  47079. /**
  47080. * Add the required uniforms to the current buffer.
  47081. * @param uniformBuffer defines the current uniform buffer.
  47082. */
  47083. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47084. /**
  47085. * Add the required samplers to the current list.
  47086. * @param samplers defines the current sampler list.
  47087. */
  47088. static AddSamplers(samplers: string[]): void;
  47089. /**
  47090. * Makes a duplicate of the current configuration into another one.
  47091. * @param anisotropicConfiguration define the config where to copy the info
  47092. */
  47093. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47094. /**
  47095. * Serializes this anisotropy configuration.
  47096. * @returns - An object with the serialized config.
  47097. */
  47098. serialize(): any;
  47099. /**
  47100. * Parses a anisotropy Configuration from a serialized object.
  47101. * @param source - Serialized object.
  47102. * @param scene Defines the scene we are parsing for
  47103. * @param rootUrl Defines the rootUrl to load from
  47104. */
  47105. parse(source: any, scene: Scene, rootUrl: string): void;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. /**
  47110. * @hidden
  47111. */
  47112. export interface IMaterialBRDFDefines {
  47113. BRDF_V_HEIGHT_CORRELATED: boolean;
  47114. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47115. SPHERICAL_HARMONICS: boolean;
  47116. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47117. /** @hidden */
  47118. _areMiscDirty: boolean;
  47119. }
  47120. /**
  47121. * Define the code related to the BRDF parameters of the pbr material.
  47122. */
  47123. export class PBRBRDFConfiguration {
  47124. /**
  47125. * Default value used for the energy conservation.
  47126. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47127. */
  47128. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47129. /**
  47130. * Default value used for the Smith Visibility Height Correlated mode.
  47131. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47132. */
  47133. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47134. /**
  47135. * Default value used for the IBL diffuse part.
  47136. * This can help switching back to the polynomials mode globally which is a tiny bit
  47137. * less GPU intensive at the drawback of a lower quality.
  47138. */
  47139. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47140. /**
  47141. * Default value used for activating energy conservation for the specular workflow.
  47142. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47143. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47144. */
  47145. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47146. private _useEnergyConservation;
  47147. /**
  47148. * Defines if the material uses energy conservation.
  47149. */
  47150. useEnergyConservation: boolean;
  47151. private _useSmithVisibilityHeightCorrelated;
  47152. /**
  47153. * LEGACY Mode set to false
  47154. * Defines if the material uses height smith correlated visibility term.
  47155. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47156. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47157. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47158. * Not relying on height correlated will also disable energy conservation.
  47159. */
  47160. useSmithVisibilityHeightCorrelated: boolean;
  47161. private _useSphericalHarmonics;
  47162. /**
  47163. * LEGACY Mode set to false
  47164. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47165. * diffuse part of the IBL.
  47166. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47167. * to the ground truth.
  47168. */
  47169. useSphericalHarmonics: boolean;
  47170. private _useSpecularGlossinessInputEnergyConservation;
  47171. /**
  47172. * Defines if the material uses energy conservation, when the specular workflow is active.
  47173. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47174. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47175. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47176. */
  47177. useSpecularGlossinessInputEnergyConservation: boolean;
  47178. /** @hidden */
  47179. private _internalMarkAllSubMeshesAsMiscDirty;
  47180. /** @hidden */
  47181. _markAllSubMeshesAsMiscDirty(): void;
  47182. /**
  47183. * Instantiate a new istance of clear coat configuration.
  47184. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47185. */
  47186. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47187. /**
  47188. * Checks to see if a texture is used in the material.
  47189. * @param defines the list of "defines" to update.
  47190. */
  47191. prepareDefines(defines: IMaterialBRDFDefines): void;
  47192. /**
  47193. * Get the current class name of the texture useful for serialization or dynamic coding.
  47194. * @returns "PBRClearCoatConfiguration"
  47195. */
  47196. getClassName(): string;
  47197. /**
  47198. * Makes a duplicate of the current configuration into another one.
  47199. * @param brdfConfiguration define the config where to copy the info
  47200. */
  47201. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47202. /**
  47203. * Serializes this BRDF configuration.
  47204. * @returns - An object with the serialized config.
  47205. */
  47206. serialize(): any;
  47207. /**
  47208. * Parses a anisotropy Configuration from a serialized object.
  47209. * @param source - Serialized object.
  47210. * @param scene Defines the scene we are parsing for
  47211. * @param rootUrl Defines the rootUrl to load from
  47212. */
  47213. parse(source: any, scene: Scene, rootUrl: string): void;
  47214. }
  47215. }
  47216. declare module BABYLON {
  47217. /**
  47218. * @hidden
  47219. */
  47220. export interface IMaterialSheenDefines {
  47221. SHEEN: boolean;
  47222. SHEEN_TEXTURE: boolean;
  47223. SHEEN_TEXTUREDIRECTUV: number;
  47224. SHEEN_LINKWITHALBEDO: boolean;
  47225. /** @hidden */
  47226. _areTexturesDirty: boolean;
  47227. }
  47228. /**
  47229. * Define the code related to the Sheen parameters of the pbr material.
  47230. */
  47231. export class PBRSheenConfiguration {
  47232. private _isEnabled;
  47233. /**
  47234. * Defines if the material uses sheen.
  47235. */
  47236. isEnabled: boolean;
  47237. private _linkSheenWithAlbedo;
  47238. /**
  47239. * Defines if the sheen is linked to the sheen color.
  47240. */
  47241. linkSheenWithAlbedo: boolean;
  47242. /**
  47243. * Defines the sheen intensity.
  47244. */
  47245. intensity: number;
  47246. /**
  47247. * Defines the sheen color.
  47248. */
  47249. color: Color3;
  47250. private _texture;
  47251. /**
  47252. * Stores the sheen tint values in a texture.
  47253. * rgb is tint
  47254. * a is a intensity
  47255. */
  47256. texture: Nullable<BaseTexture>;
  47257. /** @hidden */
  47258. private _internalMarkAllSubMeshesAsTexturesDirty;
  47259. /** @hidden */
  47260. _markAllSubMeshesAsTexturesDirty(): void;
  47261. /**
  47262. * Instantiate a new istance of clear coat configuration.
  47263. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47264. */
  47265. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47266. /**
  47267. * Specifies that the submesh is ready to be used.
  47268. * @param defines the list of "defines" to update.
  47269. * @param scene defines the scene the material belongs to.
  47270. * @returns - boolean indicating that the submesh is ready or not.
  47271. */
  47272. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47273. /**
  47274. * Checks to see if a texture is used in the material.
  47275. * @param defines the list of "defines" to update.
  47276. * @param scene defines the scene the material belongs to.
  47277. */
  47278. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47279. /**
  47280. * Binds the material data.
  47281. * @param uniformBuffer defines the Uniform buffer to fill in.
  47282. * @param scene defines the scene the material belongs to.
  47283. * @param isFrozen defines wether the material is frozen or not.
  47284. */
  47285. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47286. /**
  47287. * Checks to see if a texture is used in the material.
  47288. * @param texture - Base texture to use.
  47289. * @returns - Boolean specifying if a texture is used in the material.
  47290. */
  47291. hasTexture(texture: BaseTexture): boolean;
  47292. /**
  47293. * Returns an array of the actively used textures.
  47294. * @param activeTextures Array of BaseTextures
  47295. */
  47296. getActiveTextures(activeTextures: BaseTexture[]): void;
  47297. /**
  47298. * Returns the animatable textures.
  47299. * @param animatables Array of animatable textures.
  47300. */
  47301. getAnimatables(animatables: IAnimatable[]): void;
  47302. /**
  47303. * Disposes the resources of the material.
  47304. * @param forceDisposeTextures - Forces the disposal of all textures.
  47305. */
  47306. dispose(forceDisposeTextures?: boolean): void;
  47307. /**
  47308. * Get the current class name of the texture useful for serialization or dynamic coding.
  47309. * @returns "PBRSheenConfiguration"
  47310. */
  47311. getClassName(): string;
  47312. /**
  47313. * Add fallbacks to the effect fallbacks list.
  47314. * @param defines defines the Base texture to use.
  47315. * @param fallbacks defines the current fallback list.
  47316. * @param currentRank defines the current fallback rank.
  47317. * @returns the new fallback rank.
  47318. */
  47319. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47320. /**
  47321. * Add the required uniforms to the current list.
  47322. * @param uniforms defines the current uniform list.
  47323. */
  47324. static AddUniforms(uniforms: string[]): void;
  47325. /**
  47326. * Add the required uniforms to the current buffer.
  47327. * @param uniformBuffer defines the current uniform buffer.
  47328. */
  47329. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47330. /**
  47331. * Add the required samplers to the current list.
  47332. * @param samplers defines the current sampler list.
  47333. */
  47334. static AddSamplers(samplers: string[]): void;
  47335. /**
  47336. * Makes a duplicate of the current configuration into another one.
  47337. * @param sheenConfiguration define the config where to copy the info
  47338. */
  47339. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47340. /**
  47341. * Serializes this BRDF configuration.
  47342. * @returns - An object with the serialized config.
  47343. */
  47344. serialize(): any;
  47345. /**
  47346. * Parses a anisotropy Configuration from a serialized object.
  47347. * @param source - Serialized object.
  47348. * @param scene Defines the scene we are parsing for
  47349. * @param rootUrl Defines the rootUrl to load from
  47350. */
  47351. parse(source: any, scene: Scene, rootUrl: string): void;
  47352. }
  47353. }
  47354. declare module BABYLON {
  47355. /**
  47356. * @hidden
  47357. */
  47358. export interface IMaterialSubSurfaceDefines {
  47359. SUBSURFACE: boolean;
  47360. SS_REFRACTION: boolean;
  47361. SS_TRANSLUCENCY: boolean;
  47362. SS_SCATERRING: boolean;
  47363. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47364. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47365. SS_REFRACTIONMAP_3D: boolean;
  47366. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47367. SS_LODINREFRACTIONALPHA: boolean;
  47368. SS_GAMMAREFRACTION: boolean;
  47369. SS_RGBDREFRACTION: boolean;
  47370. SS_LINEARSPECULARREFRACTION: boolean;
  47371. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47372. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47373. /** @hidden */
  47374. _areTexturesDirty: boolean;
  47375. }
  47376. /**
  47377. * Define the code related to the sub surface parameters of the pbr material.
  47378. */
  47379. export class PBRSubSurfaceConfiguration {
  47380. private _isRefractionEnabled;
  47381. /**
  47382. * Defines if the refraction is enabled in the material.
  47383. */
  47384. isRefractionEnabled: boolean;
  47385. private _isTranslucencyEnabled;
  47386. /**
  47387. * Defines if the translucency is enabled in the material.
  47388. */
  47389. isTranslucencyEnabled: boolean;
  47390. private _isScatteringEnabled;
  47391. /**
  47392. * Defines the refraction intensity of the material.
  47393. * The refraction when enabled replaces the Diffuse part of the material.
  47394. * The intensity helps transitionning between diffuse and refraction.
  47395. */
  47396. refractionIntensity: number;
  47397. /**
  47398. * Defines the translucency intensity of the material.
  47399. * When translucency has been enabled, this defines how much of the "translucency"
  47400. * is addded to the diffuse part of the material.
  47401. */
  47402. translucencyIntensity: number;
  47403. /**
  47404. * Defines the scattering intensity of the material.
  47405. * When scattering has been enabled, this defines how much of the "scattered light"
  47406. * is addded to the diffuse part of the material.
  47407. */
  47408. scatteringIntensity: number;
  47409. private _thicknessTexture;
  47410. /**
  47411. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47412. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47413. * 0 would mean minimumThickness
  47414. * 1 would mean maximumThickness
  47415. * The other channels might be use as a mask to vary the different effects intensity.
  47416. */
  47417. thicknessTexture: Nullable<BaseTexture>;
  47418. private _refractionTexture;
  47419. /**
  47420. * Defines the texture to use for refraction.
  47421. */
  47422. refractionTexture: Nullable<BaseTexture>;
  47423. private _indexOfRefraction;
  47424. /**
  47425. * Defines the index of refraction used in the material.
  47426. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47427. */
  47428. indexOfRefraction: number;
  47429. private _invertRefractionY;
  47430. /**
  47431. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47432. */
  47433. invertRefractionY: boolean;
  47434. private _linkRefractionWithTransparency;
  47435. /**
  47436. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47437. * Materials half opaque for instance using refraction could benefit from this control.
  47438. */
  47439. linkRefractionWithTransparency: boolean;
  47440. /**
  47441. * Defines the minimum thickness stored in the thickness map.
  47442. * If no thickness map is defined, this value will be used to simulate thickness.
  47443. */
  47444. minimumThickness: number;
  47445. /**
  47446. * Defines the maximum thickness stored in the thickness map.
  47447. */
  47448. maximumThickness: number;
  47449. /**
  47450. * Defines the volume tint of the material.
  47451. * This is used for both translucency and scattering.
  47452. */
  47453. tintColor: Color3;
  47454. /**
  47455. * Defines the distance at which the tint color should be found in the media.
  47456. * This is used for refraction only.
  47457. */
  47458. tintColorAtDistance: number;
  47459. /**
  47460. * Defines how far each channel transmit through the media.
  47461. * It is defined as a color to simplify it selection.
  47462. */
  47463. diffusionDistance: Color3;
  47464. private _useMaskFromThicknessTexture;
  47465. /**
  47466. * Stores the intensity of the different subsurface effects in the thickness texture.
  47467. * * the green channel is the translucency intensity.
  47468. * * the blue channel is the scattering intensity.
  47469. * * the alpha channel is the refraction intensity.
  47470. */
  47471. useMaskFromThicknessTexture: boolean;
  47472. /** @hidden */
  47473. private _internalMarkAllSubMeshesAsTexturesDirty;
  47474. /** @hidden */
  47475. _markAllSubMeshesAsTexturesDirty(): void;
  47476. /**
  47477. * Instantiate a new istance of sub surface configuration.
  47478. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47479. */
  47480. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47481. /**
  47482. * Gets wehter the submesh is ready to be used or not.
  47483. * @param defines the list of "defines" to update.
  47484. * @param scene defines the scene the material belongs to.
  47485. * @returns - boolean indicating that the submesh is ready or not.
  47486. */
  47487. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47488. /**
  47489. * Checks to see if a texture is used in the material.
  47490. * @param defines the list of "defines" to update.
  47491. * @param scene defines the scene to the material belongs to.
  47492. */
  47493. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47494. /**
  47495. * Binds the material data.
  47496. * @param uniformBuffer defines the Uniform buffer to fill in.
  47497. * @param scene defines the scene the material belongs to.
  47498. * @param engine defines the engine the material belongs to.
  47499. * @param isFrozen defines wether the material is frozen or not.
  47500. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47501. */
  47502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47503. /**
  47504. * Unbinds the material from the mesh.
  47505. * @param activeEffect defines the effect that should be unbound from.
  47506. * @returns true if unbound, otherwise false
  47507. */
  47508. unbind(activeEffect: Effect): boolean;
  47509. /**
  47510. * Returns the texture used for refraction or null if none is used.
  47511. * @param scene defines the scene the material belongs to.
  47512. * @returns - Refraction texture if present. If no refraction texture and refraction
  47513. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47514. */
  47515. private _getRefractionTexture;
  47516. /**
  47517. * Returns true if alpha blending should be disabled.
  47518. */
  47519. readonly disableAlphaBlending: boolean;
  47520. /**
  47521. * Fills the list of render target textures.
  47522. * @param renderTargets the list of render targets to update
  47523. */
  47524. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47525. /**
  47526. * Checks to see if a texture is used in the material.
  47527. * @param texture - Base texture to use.
  47528. * @returns - Boolean specifying if a texture is used in the material.
  47529. */
  47530. hasTexture(texture: BaseTexture): boolean;
  47531. /**
  47532. * Gets a boolean indicating that current material needs to register RTT
  47533. * @returns true if this uses a render target otherwise false.
  47534. */
  47535. hasRenderTargetTextures(): boolean;
  47536. /**
  47537. * Returns an array of the actively used textures.
  47538. * @param activeTextures Array of BaseTextures
  47539. */
  47540. getActiveTextures(activeTextures: BaseTexture[]): void;
  47541. /**
  47542. * Returns the animatable textures.
  47543. * @param animatables Array of animatable textures.
  47544. */
  47545. getAnimatables(animatables: IAnimatable[]): void;
  47546. /**
  47547. * Disposes the resources of the material.
  47548. * @param forceDisposeTextures - Forces the disposal of all textures.
  47549. */
  47550. dispose(forceDisposeTextures?: boolean): void;
  47551. /**
  47552. * Get the current class name of the texture useful for serialization or dynamic coding.
  47553. * @returns "PBRSubSurfaceConfiguration"
  47554. */
  47555. getClassName(): string;
  47556. /**
  47557. * Add fallbacks to the effect fallbacks list.
  47558. * @param defines defines the Base texture to use.
  47559. * @param fallbacks defines the current fallback list.
  47560. * @param currentRank defines the current fallback rank.
  47561. * @returns the new fallback rank.
  47562. */
  47563. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47564. /**
  47565. * Add the required uniforms to the current list.
  47566. * @param uniforms defines the current uniform list.
  47567. */
  47568. static AddUniforms(uniforms: string[]): void;
  47569. /**
  47570. * Add the required samplers to the current list.
  47571. * @param samplers defines the current sampler list.
  47572. */
  47573. static AddSamplers(samplers: string[]): void;
  47574. /**
  47575. * Add the required uniforms to the current buffer.
  47576. * @param uniformBuffer defines the current uniform buffer.
  47577. */
  47578. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47579. /**
  47580. * Makes a duplicate of the current configuration into another one.
  47581. * @param configuration define the config where to copy the info
  47582. */
  47583. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47584. /**
  47585. * Serializes this Sub Surface configuration.
  47586. * @returns - An object with the serialized config.
  47587. */
  47588. serialize(): any;
  47589. /**
  47590. * Parses a anisotropy Configuration from a serialized object.
  47591. * @param source - Serialized object.
  47592. * @param scene Defines the scene we are parsing for
  47593. * @param rootUrl Defines the rootUrl to load from
  47594. */
  47595. parse(source: any, scene: Scene, rootUrl: string): void;
  47596. }
  47597. }
  47598. declare module BABYLON {
  47599. /** @hidden */
  47600. export var pbrFragmentDeclaration: {
  47601. name: string;
  47602. shader: string;
  47603. };
  47604. }
  47605. declare module BABYLON {
  47606. /** @hidden */
  47607. export var pbrUboDeclaration: {
  47608. name: string;
  47609. shader: string;
  47610. };
  47611. }
  47612. declare module BABYLON {
  47613. /** @hidden */
  47614. export var pbrFragmentExtraDeclaration: {
  47615. name: string;
  47616. shader: string;
  47617. };
  47618. }
  47619. declare module BABYLON {
  47620. /** @hidden */
  47621. export var pbrFragmentSamplersDeclaration: {
  47622. name: string;
  47623. shader: string;
  47624. };
  47625. }
  47626. declare module BABYLON {
  47627. /** @hidden */
  47628. export var pbrHelperFunctions: {
  47629. name: string;
  47630. shader: string;
  47631. };
  47632. }
  47633. declare module BABYLON {
  47634. /** @hidden */
  47635. export var harmonicsFunctions: {
  47636. name: string;
  47637. shader: string;
  47638. };
  47639. }
  47640. declare module BABYLON {
  47641. /** @hidden */
  47642. export var pbrDirectLightingSetupFunctions: {
  47643. name: string;
  47644. shader: string;
  47645. };
  47646. }
  47647. declare module BABYLON {
  47648. /** @hidden */
  47649. export var pbrDirectLightingFalloffFunctions: {
  47650. name: string;
  47651. shader: string;
  47652. };
  47653. }
  47654. declare module BABYLON {
  47655. /** @hidden */
  47656. export var pbrBRDFFunctions: {
  47657. name: string;
  47658. shader: string;
  47659. };
  47660. }
  47661. declare module BABYLON {
  47662. /** @hidden */
  47663. export var pbrDirectLightingFunctions: {
  47664. name: string;
  47665. shader: string;
  47666. };
  47667. }
  47668. declare module BABYLON {
  47669. /** @hidden */
  47670. export var pbrIBLFunctions: {
  47671. name: string;
  47672. shader: string;
  47673. };
  47674. }
  47675. declare module BABYLON {
  47676. /** @hidden */
  47677. export var pbrDebug: {
  47678. name: string;
  47679. shader: string;
  47680. };
  47681. }
  47682. declare module BABYLON {
  47683. /** @hidden */
  47684. export var pbrPixelShader: {
  47685. name: string;
  47686. shader: string;
  47687. };
  47688. }
  47689. declare module BABYLON {
  47690. /** @hidden */
  47691. export var pbrVertexDeclaration: {
  47692. name: string;
  47693. shader: string;
  47694. };
  47695. }
  47696. declare module BABYLON {
  47697. /** @hidden */
  47698. export var pbrVertexShader: {
  47699. name: string;
  47700. shader: string;
  47701. };
  47702. }
  47703. declare module BABYLON {
  47704. /**
  47705. * Manages the defines for the PBR Material.
  47706. * @hidden
  47707. */
  47708. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47709. PBR: boolean;
  47710. MAINUV1: boolean;
  47711. MAINUV2: boolean;
  47712. UV1: boolean;
  47713. UV2: boolean;
  47714. ALBEDO: boolean;
  47715. ALBEDODIRECTUV: number;
  47716. VERTEXCOLOR: boolean;
  47717. AMBIENT: boolean;
  47718. AMBIENTDIRECTUV: number;
  47719. AMBIENTINGRAYSCALE: boolean;
  47720. OPACITY: boolean;
  47721. VERTEXALPHA: boolean;
  47722. OPACITYDIRECTUV: number;
  47723. OPACITYRGB: boolean;
  47724. ALPHATEST: boolean;
  47725. DEPTHPREPASS: boolean;
  47726. ALPHABLEND: boolean;
  47727. ALPHAFROMALBEDO: boolean;
  47728. ALPHATESTVALUE: string;
  47729. SPECULAROVERALPHA: boolean;
  47730. RADIANCEOVERALPHA: boolean;
  47731. ALPHAFRESNEL: boolean;
  47732. LINEARALPHAFRESNEL: boolean;
  47733. PREMULTIPLYALPHA: boolean;
  47734. EMISSIVE: boolean;
  47735. EMISSIVEDIRECTUV: number;
  47736. REFLECTIVITY: boolean;
  47737. REFLECTIVITYDIRECTUV: number;
  47738. SPECULARTERM: boolean;
  47739. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47740. MICROSURFACEAUTOMATIC: boolean;
  47741. LODBASEDMICROSFURACE: boolean;
  47742. MICROSURFACEMAP: boolean;
  47743. MICROSURFACEMAPDIRECTUV: number;
  47744. METALLICWORKFLOW: boolean;
  47745. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47746. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47747. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47748. AOSTOREINMETALMAPRED: boolean;
  47749. METALLICF0FACTORFROMMETALLICMAP: boolean;
  47750. ENVIRONMENTBRDF: boolean;
  47751. ENVIRONMENTBRDF_RGBD: boolean;
  47752. NORMAL: boolean;
  47753. TANGENT: boolean;
  47754. BUMP: boolean;
  47755. BUMPDIRECTUV: number;
  47756. OBJECTSPACE_NORMALMAP: boolean;
  47757. PARALLAX: boolean;
  47758. PARALLAXOCCLUSION: boolean;
  47759. NORMALXYSCALE: boolean;
  47760. LIGHTMAP: boolean;
  47761. LIGHTMAPDIRECTUV: number;
  47762. USELIGHTMAPASSHADOWMAP: boolean;
  47763. GAMMALIGHTMAP: boolean;
  47764. RGBDLIGHTMAP: boolean;
  47765. REFLECTION: boolean;
  47766. REFLECTIONMAP_3D: boolean;
  47767. REFLECTIONMAP_SPHERICAL: boolean;
  47768. REFLECTIONMAP_PLANAR: boolean;
  47769. REFLECTIONMAP_CUBIC: boolean;
  47770. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47771. REFLECTIONMAP_PROJECTION: boolean;
  47772. REFLECTIONMAP_SKYBOX: boolean;
  47773. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47774. REFLECTIONMAP_EXPLICIT: boolean;
  47775. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47776. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47777. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47778. INVERTCUBICMAP: boolean;
  47779. USESPHERICALFROMREFLECTIONMAP: boolean;
  47780. USEIRRADIANCEMAP: boolean;
  47781. SPHERICAL_HARMONICS: boolean;
  47782. USESPHERICALINVERTEX: boolean;
  47783. REFLECTIONMAP_OPPOSITEZ: boolean;
  47784. LODINREFLECTIONALPHA: boolean;
  47785. GAMMAREFLECTION: boolean;
  47786. RGBDREFLECTION: boolean;
  47787. LINEARSPECULARREFLECTION: boolean;
  47788. RADIANCEOCCLUSION: boolean;
  47789. HORIZONOCCLUSION: boolean;
  47790. INSTANCES: boolean;
  47791. NUM_BONE_INFLUENCERS: number;
  47792. BonesPerMesh: number;
  47793. BONETEXTURE: boolean;
  47794. NONUNIFORMSCALING: boolean;
  47795. MORPHTARGETS: boolean;
  47796. MORPHTARGETS_NORMAL: boolean;
  47797. MORPHTARGETS_TANGENT: boolean;
  47798. MORPHTARGETS_UV: boolean;
  47799. NUM_MORPH_INFLUENCERS: number;
  47800. IMAGEPROCESSING: boolean;
  47801. VIGNETTE: boolean;
  47802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47803. VIGNETTEBLENDMODEOPAQUE: boolean;
  47804. TONEMAPPING: boolean;
  47805. TONEMAPPING_ACES: boolean;
  47806. CONTRAST: boolean;
  47807. COLORCURVES: boolean;
  47808. COLORGRADING: boolean;
  47809. COLORGRADING3D: boolean;
  47810. SAMPLER3DGREENDEPTH: boolean;
  47811. SAMPLER3DBGRMAP: boolean;
  47812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47813. EXPOSURE: boolean;
  47814. MULTIVIEW: boolean;
  47815. USEPHYSICALLIGHTFALLOFF: boolean;
  47816. USEGLTFLIGHTFALLOFF: boolean;
  47817. TWOSIDEDLIGHTING: boolean;
  47818. SHADOWFLOAT: boolean;
  47819. CLIPPLANE: boolean;
  47820. CLIPPLANE2: boolean;
  47821. CLIPPLANE3: boolean;
  47822. CLIPPLANE4: boolean;
  47823. POINTSIZE: boolean;
  47824. FOG: boolean;
  47825. LOGARITHMICDEPTH: boolean;
  47826. FORCENORMALFORWARD: boolean;
  47827. SPECULARAA: boolean;
  47828. CLEARCOAT: boolean;
  47829. CLEARCOAT_DEFAULTIOR: boolean;
  47830. CLEARCOAT_TEXTURE: boolean;
  47831. CLEARCOAT_TEXTUREDIRECTUV: number;
  47832. CLEARCOAT_BUMP: boolean;
  47833. CLEARCOAT_BUMPDIRECTUV: number;
  47834. CLEARCOAT_TINT: boolean;
  47835. CLEARCOAT_TINT_TEXTURE: boolean;
  47836. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47837. ANISOTROPIC: boolean;
  47838. ANISOTROPIC_TEXTURE: boolean;
  47839. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47840. BRDF_V_HEIGHT_CORRELATED: boolean;
  47841. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47842. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47843. SHEEN: boolean;
  47844. SHEEN_TEXTURE: boolean;
  47845. SHEEN_TEXTUREDIRECTUV: number;
  47846. SHEEN_LINKWITHALBEDO: boolean;
  47847. SUBSURFACE: boolean;
  47848. SS_REFRACTION: boolean;
  47849. SS_TRANSLUCENCY: boolean;
  47850. SS_SCATERRING: boolean;
  47851. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47852. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47853. SS_REFRACTIONMAP_3D: boolean;
  47854. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47855. SS_LODINREFRACTIONALPHA: boolean;
  47856. SS_GAMMAREFRACTION: boolean;
  47857. SS_RGBDREFRACTION: boolean;
  47858. SS_LINEARSPECULARREFRACTION: boolean;
  47859. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47860. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47861. UNLIT: boolean;
  47862. DEBUGMODE: number;
  47863. /**
  47864. * Initializes the PBR Material defines.
  47865. */
  47866. constructor();
  47867. /**
  47868. * Resets the PBR Material defines.
  47869. */
  47870. reset(): void;
  47871. }
  47872. /**
  47873. * The Physically based material base class of BJS.
  47874. *
  47875. * This offers the main features of a standard PBR material.
  47876. * For more information, please refer to the documentation :
  47877. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47878. */
  47879. export abstract class PBRBaseMaterial extends PushMaterial {
  47880. /**
  47881. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47882. */
  47883. static readonly PBRMATERIAL_OPAQUE: number;
  47884. /**
  47885. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47886. */
  47887. static readonly PBRMATERIAL_ALPHATEST: number;
  47888. /**
  47889. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47890. */
  47891. static readonly PBRMATERIAL_ALPHABLEND: number;
  47892. /**
  47893. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47894. * They are also discarded below the alpha cutoff threshold to improve performances.
  47895. */
  47896. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47897. /**
  47898. * Defines the default value of how much AO map is occluding the analytical lights
  47899. * (point spot...).
  47900. */
  47901. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47902. /**
  47903. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47904. */
  47905. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47906. /**
  47907. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47908. * to enhance interoperability with other engines.
  47909. */
  47910. static readonly LIGHTFALLOFF_GLTF: number;
  47911. /**
  47912. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47913. * to enhance interoperability with other materials.
  47914. */
  47915. static readonly LIGHTFALLOFF_STANDARD: number;
  47916. /**
  47917. * Intensity of the direct lights e.g. the four lights available in your scene.
  47918. * This impacts both the direct diffuse and specular highlights.
  47919. */
  47920. protected _directIntensity: number;
  47921. /**
  47922. * Intensity of the emissive part of the material.
  47923. * This helps controlling the emissive effect without modifying the emissive color.
  47924. */
  47925. protected _emissiveIntensity: number;
  47926. /**
  47927. * Intensity of the environment e.g. how much the environment will light the object
  47928. * either through harmonics for rough material or through the refelction for shiny ones.
  47929. */
  47930. protected _environmentIntensity: number;
  47931. /**
  47932. * This is a special control allowing the reduction of the specular highlights coming from the
  47933. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47934. */
  47935. protected _specularIntensity: number;
  47936. /**
  47937. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47938. */
  47939. private _lightingInfos;
  47940. /**
  47941. * Debug Control allowing disabling the bump map on this material.
  47942. */
  47943. protected _disableBumpMap: boolean;
  47944. /**
  47945. * AKA Diffuse Texture in standard nomenclature.
  47946. */
  47947. protected _albedoTexture: Nullable<BaseTexture>;
  47948. /**
  47949. * AKA Occlusion Texture in other nomenclature.
  47950. */
  47951. protected _ambientTexture: Nullable<BaseTexture>;
  47952. /**
  47953. * AKA Occlusion Texture Intensity in other nomenclature.
  47954. */
  47955. protected _ambientTextureStrength: number;
  47956. /**
  47957. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47958. * 1 means it completely occludes it
  47959. * 0 mean it has no impact
  47960. */
  47961. protected _ambientTextureImpactOnAnalyticalLights: number;
  47962. /**
  47963. * Stores the alpha values in a texture.
  47964. */
  47965. protected _opacityTexture: Nullable<BaseTexture>;
  47966. /**
  47967. * Stores the reflection values in a texture.
  47968. */
  47969. protected _reflectionTexture: Nullable<BaseTexture>;
  47970. /**
  47971. * Stores the emissive values in a texture.
  47972. */
  47973. protected _emissiveTexture: Nullable<BaseTexture>;
  47974. /**
  47975. * AKA Specular texture in other nomenclature.
  47976. */
  47977. protected _reflectivityTexture: Nullable<BaseTexture>;
  47978. /**
  47979. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47980. */
  47981. protected _metallicTexture: Nullable<BaseTexture>;
  47982. /**
  47983. * Specifies the metallic scalar of the metallic/roughness workflow.
  47984. * Can also be used to scale the metalness values of the metallic texture.
  47985. */
  47986. protected _metallic: Nullable<number>;
  47987. /**
  47988. * Specifies the roughness scalar of the metallic/roughness workflow.
  47989. * Can also be used to scale the roughness values of the metallic texture.
  47990. */
  47991. protected _roughness: Nullable<number>;
  47992. /**
  47993. * Specifies the an F0 factor to help configuring the material F0.
  47994. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  47995. * to 0.5 the previously hard coded value stays the same.
  47996. * Can also be used to scale the F0 values of the metallic texture.
  47997. */
  47998. protected _metallicF0Factor: number;
  47999. /**
  48000. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48001. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48002. * your expectation as it multiplies with the texture data.
  48003. */
  48004. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48005. /**
  48006. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48007. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48008. */
  48009. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48010. /**
  48011. * Stores surface normal data used to displace a mesh in a texture.
  48012. */
  48013. protected _bumpTexture: Nullable<BaseTexture>;
  48014. /**
  48015. * Stores the pre-calculated light information of a mesh in a texture.
  48016. */
  48017. protected _lightmapTexture: Nullable<BaseTexture>;
  48018. /**
  48019. * The color of a material in ambient lighting.
  48020. */
  48021. protected _ambientColor: Color3;
  48022. /**
  48023. * AKA Diffuse Color in other nomenclature.
  48024. */
  48025. protected _albedoColor: Color3;
  48026. /**
  48027. * AKA Specular Color in other nomenclature.
  48028. */
  48029. protected _reflectivityColor: Color3;
  48030. /**
  48031. * The color applied when light is reflected from a material.
  48032. */
  48033. protected _reflectionColor: Color3;
  48034. /**
  48035. * The color applied when light is emitted from a material.
  48036. */
  48037. protected _emissiveColor: Color3;
  48038. /**
  48039. * AKA Glossiness in other nomenclature.
  48040. */
  48041. protected _microSurface: number;
  48042. /**
  48043. * Specifies that the material will use the light map as a show map.
  48044. */
  48045. protected _useLightmapAsShadowmap: boolean;
  48046. /**
  48047. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48048. * makes the reflect vector face the model (under horizon).
  48049. */
  48050. protected _useHorizonOcclusion: boolean;
  48051. /**
  48052. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48053. * too much the area relying on ambient texture to define their ambient occlusion.
  48054. */
  48055. protected _useRadianceOcclusion: boolean;
  48056. /**
  48057. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48058. */
  48059. protected _useAlphaFromAlbedoTexture: boolean;
  48060. /**
  48061. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48062. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48063. */
  48064. protected _useSpecularOverAlpha: boolean;
  48065. /**
  48066. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48067. */
  48068. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48069. /**
  48070. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48071. */
  48072. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48073. /**
  48074. * Specifies if the metallic texture contains the roughness information in its green channel.
  48075. */
  48076. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48077. /**
  48078. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48079. */
  48080. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48081. /**
  48082. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48083. */
  48084. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48085. /**
  48086. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48087. */
  48088. protected _useAmbientInGrayScale: boolean;
  48089. /**
  48090. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48091. * The material will try to infer what glossiness each pixel should be.
  48092. */
  48093. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48094. /**
  48095. * Defines the falloff type used in this material.
  48096. * It by default is Physical.
  48097. */
  48098. protected _lightFalloff: number;
  48099. /**
  48100. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48101. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48102. */
  48103. protected _useRadianceOverAlpha: boolean;
  48104. /**
  48105. * Allows using an object space normal map (instead of tangent space).
  48106. */
  48107. protected _useObjectSpaceNormalMap: boolean;
  48108. /**
  48109. * Allows using the bump map in parallax mode.
  48110. */
  48111. protected _useParallax: boolean;
  48112. /**
  48113. * Allows using the bump map in parallax occlusion mode.
  48114. */
  48115. protected _useParallaxOcclusion: boolean;
  48116. /**
  48117. * Controls the scale bias of the parallax mode.
  48118. */
  48119. protected _parallaxScaleBias: number;
  48120. /**
  48121. * If sets to true, disables all the lights affecting the material.
  48122. */
  48123. protected _disableLighting: boolean;
  48124. /**
  48125. * Number of Simultaneous lights allowed on the material.
  48126. */
  48127. protected _maxSimultaneousLights: number;
  48128. /**
  48129. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48130. */
  48131. protected _invertNormalMapX: boolean;
  48132. /**
  48133. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48134. */
  48135. protected _invertNormalMapY: boolean;
  48136. /**
  48137. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48138. */
  48139. protected _twoSidedLighting: boolean;
  48140. /**
  48141. * Defines the alpha limits in alpha test mode.
  48142. */
  48143. protected _alphaCutOff: number;
  48144. /**
  48145. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48146. */
  48147. protected _forceAlphaTest: boolean;
  48148. /**
  48149. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48150. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48151. */
  48152. protected _useAlphaFresnel: boolean;
  48153. /**
  48154. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48155. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48156. */
  48157. protected _useLinearAlphaFresnel: boolean;
  48158. /**
  48159. * The transparency mode of the material.
  48160. */
  48161. protected _transparencyMode: Nullable<number>;
  48162. /**
  48163. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48164. * from cos thetav and roughness:
  48165. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48166. */
  48167. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48168. /**
  48169. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48170. */
  48171. protected _forceIrradianceInFragment: boolean;
  48172. /**
  48173. * Force normal to face away from face.
  48174. */
  48175. protected _forceNormalForward: boolean;
  48176. /**
  48177. * Enables specular anti aliasing in the PBR shader.
  48178. * It will both interacts on the Geometry for analytical and IBL lighting.
  48179. * It also prefilter the roughness map based on the bump values.
  48180. */
  48181. protected _enableSpecularAntiAliasing: boolean;
  48182. /**
  48183. * Default configuration related to image processing available in the PBR Material.
  48184. */
  48185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48186. /**
  48187. * Keep track of the image processing observer to allow dispose and replace.
  48188. */
  48189. private _imageProcessingObserver;
  48190. /**
  48191. * Attaches a new image processing configuration to the PBR Material.
  48192. * @param configuration
  48193. */
  48194. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48195. /**
  48196. * Stores the available render targets.
  48197. */
  48198. private _renderTargets;
  48199. /**
  48200. * Sets the global ambient color for the material used in lighting calculations.
  48201. */
  48202. private _globalAmbientColor;
  48203. /**
  48204. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48205. */
  48206. private _useLogarithmicDepth;
  48207. /**
  48208. * If set to true, no lighting calculations will be applied.
  48209. */
  48210. private _unlit;
  48211. private _debugMode;
  48212. /**
  48213. * @hidden
  48214. * This is reserved for the inspector.
  48215. * Defines the material debug mode.
  48216. * It helps seeing only some components of the material while troubleshooting.
  48217. */
  48218. debugMode: number;
  48219. /**
  48220. * @hidden
  48221. * This is reserved for the inspector.
  48222. * Specify from where on screen the debug mode should start.
  48223. * The value goes from -1 (full screen) to 1 (not visible)
  48224. * It helps with side by side comparison against the final render
  48225. * This defaults to -1
  48226. */
  48227. private debugLimit;
  48228. /**
  48229. * @hidden
  48230. * This is reserved for the inspector.
  48231. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48232. * You can use the factor to better multiply the final value.
  48233. */
  48234. private debugFactor;
  48235. /**
  48236. * Defines the clear coat layer parameters for the material.
  48237. */
  48238. readonly clearCoat: PBRClearCoatConfiguration;
  48239. /**
  48240. * Defines the anisotropic parameters for the material.
  48241. */
  48242. readonly anisotropy: PBRAnisotropicConfiguration;
  48243. /**
  48244. * Defines the BRDF parameters for the material.
  48245. */
  48246. readonly brdf: PBRBRDFConfiguration;
  48247. /**
  48248. * Defines the Sheen parameters for the material.
  48249. */
  48250. readonly sheen: PBRSheenConfiguration;
  48251. /**
  48252. * Defines the SubSurface parameters for the material.
  48253. */
  48254. readonly subSurface: PBRSubSurfaceConfiguration;
  48255. /**
  48256. * Custom callback helping to override the default shader used in the material.
  48257. */
  48258. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48259. protected _rebuildInParallel: boolean;
  48260. /**
  48261. * Instantiates a new PBRMaterial instance.
  48262. *
  48263. * @param name The material name
  48264. * @param scene The scene the material will be use in.
  48265. */
  48266. constructor(name: string, scene: Scene);
  48267. /**
  48268. * Gets a boolean indicating that current material needs to register RTT
  48269. */
  48270. readonly hasRenderTargetTextures: boolean;
  48271. /**
  48272. * Gets the name of the material class.
  48273. */
  48274. getClassName(): string;
  48275. /**
  48276. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48277. */
  48278. /**
  48279. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48280. */
  48281. useLogarithmicDepth: boolean;
  48282. /**
  48283. * Gets the current transparency mode.
  48284. */
  48285. /**
  48286. * Sets the transparency mode of the material.
  48287. *
  48288. * | Value | Type | Description |
  48289. * | ----- | ----------------------------------- | ----------- |
  48290. * | 0 | OPAQUE | |
  48291. * | 1 | ALPHATEST | |
  48292. * | 2 | ALPHABLEND | |
  48293. * | 3 | ALPHATESTANDBLEND | |
  48294. *
  48295. */
  48296. transparencyMode: Nullable<number>;
  48297. /**
  48298. * Returns true if alpha blending should be disabled.
  48299. */
  48300. private readonly _disableAlphaBlending;
  48301. /**
  48302. * Specifies whether or not this material should be rendered in alpha blend mode.
  48303. */
  48304. needAlphaBlending(): boolean;
  48305. /**
  48306. * Specifies if the mesh will require alpha blending.
  48307. * @param mesh - BJS mesh.
  48308. */
  48309. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48310. /**
  48311. * Specifies whether or not this material should be rendered in alpha test mode.
  48312. */
  48313. needAlphaTesting(): boolean;
  48314. /**
  48315. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48316. */
  48317. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48318. /**
  48319. * Gets the texture used for the alpha test.
  48320. */
  48321. getAlphaTestTexture(): Nullable<BaseTexture>;
  48322. /**
  48323. * Specifies that the submesh is ready to be used.
  48324. * @param mesh - BJS mesh.
  48325. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48326. * @param useInstances - Specifies that instances should be used.
  48327. * @returns - boolean indicating that the submesh is ready or not.
  48328. */
  48329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48330. /**
  48331. * Specifies if the material uses metallic roughness workflow.
  48332. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48333. */
  48334. isMetallicWorkflow(): boolean;
  48335. private _prepareEffect;
  48336. private _prepareDefines;
  48337. /**
  48338. * Force shader compilation
  48339. */
  48340. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48341. /**
  48342. * Initializes the uniform buffer layout for the shader.
  48343. */
  48344. buildUniformLayout(): void;
  48345. /**
  48346. * Unbinds the material from the mesh
  48347. */
  48348. unbind(): void;
  48349. /**
  48350. * Binds the submesh data.
  48351. * @param world - The world matrix.
  48352. * @param mesh - The BJS mesh.
  48353. * @param subMesh - A submesh of the BJS mesh.
  48354. */
  48355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48356. /**
  48357. * Returns the animatable textures.
  48358. * @returns - Array of animatable textures.
  48359. */
  48360. getAnimatables(): IAnimatable[];
  48361. /**
  48362. * Returns the texture used for reflections.
  48363. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48364. */
  48365. private _getReflectionTexture;
  48366. /**
  48367. * Returns an array of the actively used textures.
  48368. * @returns - Array of BaseTextures
  48369. */
  48370. getActiveTextures(): BaseTexture[];
  48371. /**
  48372. * Checks to see if a texture is used in the material.
  48373. * @param texture - Base texture to use.
  48374. * @returns - Boolean specifying if a texture is used in the material.
  48375. */
  48376. hasTexture(texture: BaseTexture): boolean;
  48377. /**
  48378. * Disposes the resources of the material.
  48379. * @param forceDisposeEffect - Forces the disposal of effects.
  48380. * @param forceDisposeTextures - Forces the disposal of all textures.
  48381. */
  48382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48383. }
  48384. }
  48385. declare module BABYLON {
  48386. /**
  48387. * The Physically based material of BJS.
  48388. *
  48389. * This offers the main features of a standard PBR material.
  48390. * For more information, please refer to the documentation :
  48391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48392. */
  48393. export class PBRMaterial extends PBRBaseMaterial {
  48394. /**
  48395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48396. */
  48397. static readonly PBRMATERIAL_OPAQUE: number;
  48398. /**
  48399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48400. */
  48401. static readonly PBRMATERIAL_ALPHATEST: number;
  48402. /**
  48403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48404. */
  48405. static readonly PBRMATERIAL_ALPHABLEND: number;
  48406. /**
  48407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48408. * They are also discarded below the alpha cutoff threshold to improve performances.
  48409. */
  48410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48411. /**
  48412. * Defines the default value of how much AO map is occluding the analytical lights
  48413. * (point spot...).
  48414. */
  48415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48416. /**
  48417. * Intensity of the direct lights e.g. the four lights available in your scene.
  48418. * This impacts both the direct diffuse and specular highlights.
  48419. */
  48420. directIntensity: number;
  48421. /**
  48422. * Intensity of the emissive part of the material.
  48423. * This helps controlling the emissive effect without modifying the emissive color.
  48424. */
  48425. emissiveIntensity: number;
  48426. /**
  48427. * Intensity of the environment e.g. how much the environment will light the object
  48428. * either through harmonics for rough material or through the refelction for shiny ones.
  48429. */
  48430. environmentIntensity: number;
  48431. /**
  48432. * This is a special control allowing the reduction of the specular highlights coming from the
  48433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48434. */
  48435. specularIntensity: number;
  48436. /**
  48437. * Debug Control allowing disabling the bump map on this material.
  48438. */
  48439. disableBumpMap: boolean;
  48440. /**
  48441. * AKA Diffuse Texture in standard nomenclature.
  48442. */
  48443. albedoTexture: BaseTexture;
  48444. /**
  48445. * AKA Occlusion Texture in other nomenclature.
  48446. */
  48447. ambientTexture: BaseTexture;
  48448. /**
  48449. * AKA Occlusion Texture Intensity in other nomenclature.
  48450. */
  48451. ambientTextureStrength: number;
  48452. /**
  48453. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48454. * 1 means it completely occludes it
  48455. * 0 mean it has no impact
  48456. */
  48457. ambientTextureImpactOnAnalyticalLights: number;
  48458. /**
  48459. * Stores the alpha values in a texture.
  48460. */
  48461. opacityTexture: BaseTexture;
  48462. /**
  48463. * Stores the reflection values in a texture.
  48464. */
  48465. reflectionTexture: Nullable<BaseTexture>;
  48466. /**
  48467. * Stores the emissive values in a texture.
  48468. */
  48469. emissiveTexture: BaseTexture;
  48470. /**
  48471. * AKA Specular texture in other nomenclature.
  48472. */
  48473. reflectivityTexture: BaseTexture;
  48474. /**
  48475. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48476. */
  48477. metallicTexture: BaseTexture;
  48478. /**
  48479. * Specifies the metallic scalar of the metallic/roughness workflow.
  48480. * Can also be used to scale the metalness values of the metallic texture.
  48481. */
  48482. metallic: Nullable<number>;
  48483. /**
  48484. * Specifies the roughness scalar of the metallic/roughness workflow.
  48485. * Can also be used to scale the roughness values of the metallic texture.
  48486. */
  48487. roughness: Nullable<number>;
  48488. /**
  48489. * Specifies the an F0 factor to help configuring the material F0.
  48490. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48491. * to 0.5 the previously hard coded value stays the same.
  48492. * Can also be used to scale the F0 values of the metallic texture.
  48493. */
  48494. metallicF0Factor: number;
  48495. /**
  48496. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48497. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48498. * your expectation as it multiplies with the texture data.
  48499. */
  48500. useMetallicF0FactorFromMetallicTexture: boolean;
  48501. /**
  48502. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48503. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48504. */
  48505. microSurfaceTexture: BaseTexture;
  48506. /**
  48507. * Stores surface normal data used to displace a mesh in a texture.
  48508. */
  48509. bumpTexture: BaseTexture;
  48510. /**
  48511. * Stores the pre-calculated light information of a mesh in a texture.
  48512. */
  48513. lightmapTexture: BaseTexture;
  48514. /**
  48515. * Stores the refracted light information in a texture.
  48516. */
  48517. refractionTexture: Nullable<BaseTexture>;
  48518. /**
  48519. * The color of a material in ambient lighting.
  48520. */
  48521. ambientColor: Color3;
  48522. /**
  48523. * AKA Diffuse Color in other nomenclature.
  48524. */
  48525. albedoColor: Color3;
  48526. /**
  48527. * AKA Specular Color in other nomenclature.
  48528. */
  48529. reflectivityColor: Color3;
  48530. /**
  48531. * The color reflected from the material.
  48532. */
  48533. reflectionColor: Color3;
  48534. /**
  48535. * The color emitted from the material.
  48536. */
  48537. emissiveColor: Color3;
  48538. /**
  48539. * AKA Glossiness in other nomenclature.
  48540. */
  48541. microSurface: number;
  48542. /**
  48543. * source material index of refraction (IOR)' / 'destination material IOR.
  48544. */
  48545. indexOfRefraction: number;
  48546. /**
  48547. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48548. */
  48549. invertRefractionY: boolean;
  48550. /**
  48551. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48552. * Materials half opaque for instance using refraction could benefit from this control.
  48553. */
  48554. linkRefractionWithTransparency: boolean;
  48555. /**
  48556. * If true, the light map contains occlusion information instead of lighting info.
  48557. */
  48558. useLightmapAsShadowmap: boolean;
  48559. /**
  48560. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48561. */
  48562. useAlphaFromAlbedoTexture: boolean;
  48563. /**
  48564. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48565. */
  48566. forceAlphaTest: boolean;
  48567. /**
  48568. * Defines the alpha limits in alpha test mode.
  48569. */
  48570. alphaCutOff: number;
  48571. /**
  48572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48574. */
  48575. useSpecularOverAlpha: boolean;
  48576. /**
  48577. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48578. */
  48579. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48580. /**
  48581. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48582. */
  48583. useRoughnessFromMetallicTextureAlpha: boolean;
  48584. /**
  48585. * Specifies if the metallic texture contains the roughness information in its green channel.
  48586. */
  48587. useRoughnessFromMetallicTextureGreen: boolean;
  48588. /**
  48589. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48590. */
  48591. useMetallnessFromMetallicTextureBlue: boolean;
  48592. /**
  48593. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48594. */
  48595. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48596. /**
  48597. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48598. */
  48599. useAmbientInGrayScale: boolean;
  48600. /**
  48601. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48602. * The material will try to infer what glossiness each pixel should be.
  48603. */
  48604. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48605. /**
  48606. * BJS is using an harcoded light falloff based on a manually sets up range.
  48607. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48608. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48609. */
  48610. /**
  48611. * BJS is using an harcoded light falloff based on a manually sets up range.
  48612. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48613. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48614. */
  48615. usePhysicalLightFalloff: boolean;
  48616. /**
  48617. * In order to support the falloff compatibility with gltf, a special mode has been added
  48618. * to reproduce the gltf light falloff.
  48619. */
  48620. /**
  48621. * In order to support the falloff compatibility with gltf, a special mode has been added
  48622. * to reproduce the gltf light falloff.
  48623. */
  48624. useGLTFLightFalloff: boolean;
  48625. /**
  48626. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48627. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48628. */
  48629. useRadianceOverAlpha: boolean;
  48630. /**
  48631. * Allows using an object space normal map (instead of tangent space).
  48632. */
  48633. useObjectSpaceNormalMap: boolean;
  48634. /**
  48635. * Allows using the bump map in parallax mode.
  48636. */
  48637. useParallax: boolean;
  48638. /**
  48639. * Allows using the bump map in parallax occlusion mode.
  48640. */
  48641. useParallaxOcclusion: boolean;
  48642. /**
  48643. * Controls the scale bias of the parallax mode.
  48644. */
  48645. parallaxScaleBias: number;
  48646. /**
  48647. * If sets to true, disables all the lights affecting the material.
  48648. */
  48649. disableLighting: boolean;
  48650. /**
  48651. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48652. */
  48653. forceIrradianceInFragment: boolean;
  48654. /**
  48655. * Number of Simultaneous lights allowed on the material.
  48656. */
  48657. maxSimultaneousLights: number;
  48658. /**
  48659. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48660. */
  48661. invertNormalMapX: boolean;
  48662. /**
  48663. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48664. */
  48665. invertNormalMapY: boolean;
  48666. /**
  48667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48668. */
  48669. twoSidedLighting: boolean;
  48670. /**
  48671. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48672. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48673. */
  48674. useAlphaFresnel: boolean;
  48675. /**
  48676. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48677. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48678. */
  48679. useLinearAlphaFresnel: boolean;
  48680. /**
  48681. * Let user defines the brdf lookup texture used for IBL.
  48682. * A default 8bit version is embedded but you could point at :
  48683. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48684. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48685. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48686. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48687. */
  48688. environmentBRDFTexture: Nullable<BaseTexture>;
  48689. /**
  48690. * Force normal to face away from face.
  48691. */
  48692. forceNormalForward: boolean;
  48693. /**
  48694. * Enables specular anti aliasing in the PBR shader.
  48695. * It will both interacts on the Geometry for analytical and IBL lighting.
  48696. * It also prefilter the roughness map based on the bump values.
  48697. */
  48698. enableSpecularAntiAliasing: boolean;
  48699. /**
  48700. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48701. * makes the reflect vector face the model (under horizon).
  48702. */
  48703. useHorizonOcclusion: boolean;
  48704. /**
  48705. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48706. * too much the area relying on ambient texture to define their ambient occlusion.
  48707. */
  48708. useRadianceOcclusion: boolean;
  48709. /**
  48710. * If set to true, no lighting calculations will be applied.
  48711. */
  48712. unlit: boolean;
  48713. /**
  48714. * Gets the image processing configuration used either in this material.
  48715. */
  48716. /**
  48717. * Sets the Default image processing configuration used either in the this material.
  48718. *
  48719. * If sets to null, the scene one is in use.
  48720. */
  48721. imageProcessingConfiguration: ImageProcessingConfiguration;
  48722. /**
  48723. * Gets wether the color curves effect is enabled.
  48724. */
  48725. /**
  48726. * Sets wether the color curves effect is enabled.
  48727. */
  48728. cameraColorCurvesEnabled: boolean;
  48729. /**
  48730. * Gets wether the color grading effect is enabled.
  48731. */
  48732. /**
  48733. * Gets wether the color grading effect is enabled.
  48734. */
  48735. cameraColorGradingEnabled: boolean;
  48736. /**
  48737. * Gets wether tonemapping is enabled or not.
  48738. */
  48739. /**
  48740. * Sets wether tonemapping is enabled or not
  48741. */
  48742. cameraToneMappingEnabled: boolean;
  48743. /**
  48744. * The camera exposure used on this material.
  48745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48746. * This corresponds to a photographic exposure.
  48747. */
  48748. /**
  48749. * The camera exposure used on this material.
  48750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48751. * This corresponds to a photographic exposure.
  48752. */
  48753. cameraExposure: number;
  48754. /**
  48755. * Gets The camera contrast used on this material.
  48756. */
  48757. /**
  48758. * Sets The camera contrast used on this material.
  48759. */
  48760. cameraContrast: number;
  48761. /**
  48762. * Gets the Color Grading 2D Lookup Texture.
  48763. */
  48764. /**
  48765. * Sets the Color Grading 2D Lookup Texture.
  48766. */
  48767. cameraColorGradingTexture: Nullable<BaseTexture>;
  48768. /**
  48769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48771. * 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;
  48772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48773. */
  48774. /**
  48775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48777. * 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;
  48778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48779. */
  48780. cameraColorCurves: Nullable<ColorCurves>;
  48781. /**
  48782. * Instantiates a new PBRMaterial instance.
  48783. *
  48784. * @param name The material name
  48785. * @param scene The scene the material will be use in.
  48786. */
  48787. constructor(name: string, scene: Scene);
  48788. /**
  48789. * Returns the name of this material class.
  48790. */
  48791. getClassName(): string;
  48792. /**
  48793. * Makes a duplicate of the current material.
  48794. * @param name - name to use for the new material.
  48795. */
  48796. clone(name: string): PBRMaterial;
  48797. /**
  48798. * Serializes this PBR Material.
  48799. * @returns - An object with the serialized material.
  48800. */
  48801. serialize(): any;
  48802. /**
  48803. * Parses a PBR Material from a serialized object.
  48804. * @param source - Serialized object.
  48805. * @param scene - BJS scene instance.
  48806. * @param rootUrl - url for the scene object
  48807. * @returns - PBRMaterial
  48808. */
  48809. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48810. }
  48811. }
  48812. declare module BABYLON {
  48813. /**
  48814. * Direct draw surface info
  48815. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48816. */
  48817. export interface DDSInfo {
  48818. /**
  48819. * Width of the texture
  48820. */
  48821. width: number;
  48822. /**
  48823. * Width of the texture
  48824. */
  48825. height: number;
  48826. /**
  48827. * Number of Mipmaps for the texture
  48828. * @see https://en.wikipedia.org/wiki/Mipmap
  48829. */
  48830. mipmapCount: number;
  48831. /**
  48832. * If the textures format is a known fourCC format
  48833. * @see https://www.fourcc.org/
  48834. */
  48835. isFourCC: boolean;
  48836. /**
  48837. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48838. */
  48839. isRGB: boolean;
  48840. /**
  48841. * If the texture is a lumincance format
  48842. */
  48843. isLuminance: boolean;
  48844. /**
  48845. * If this is a cube texture
  48846. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48847. */
  48848. isCube: boolean;
  48849. /**
  48850. * If the texture is a compressed format eg. FOURCC_DXT1
  48851. */
  48852. isCompressed: boolean;
  48853. /**
  48854. * The dxgiFormat of the texture
  48855. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48856. */
  48857. dxgiFormat: number;
  48858. /**
  48859. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48860. */
  48861. textureType: number;
  48862. /**
  48863. * Sphericle polynomial created for the dds texture
  48864. */
  48865. sphericalPolynomial?: SphericalPolynomial;
  48866. }
  48867. /**
  48868. * Class used to provide DDS decompression tools
  48869. */
  48870. export class DDSTools {
  48871. /**
  48872. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48873. */
  48874. static StoreLODInAlphaChannel: boolean;
  48875. /**
  48876. * Gets DDS information from an array buffer
  48877. * @param arrayBuffer defines the array buffer to read data from
  48878. * @returns the DDS information
  48879. */
  48880. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48881. private static _FloatView;
  48882. private static _Int32View;
  48883. private static _ToHalfFloat;
  48884. private static _FromHalfFloat;
  48885. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48886. private static _GetHalfFloatRGBAArrayBuffer;
  48887. private static _GetFloatRGBAArrayBuffer;
  48888. private static _GetFloatAsUIntRGBAArrayBuffer;
  48889. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48890. private static _GetRGBAArrayBuffer;
  48891. private static _ExtractLongWordOrder;
  48892. private static _GetRGBArrayBuffer;
  48893. private static _GetLuminanceArrayBuffer;
  48894. /**
  48895. * Uploads DDS Levels to a Babylon Texture
  48896. * @hidden
  48897. */
  48898. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48899. }
  48900. interface ThinEngine {
  48901. /**
  48902. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48903. * @param rootUrl defines the url where the file to load is located
  48904. * @param scene defines the current scene
  48905. * @param lodScale defines scale to apply to the mip map selection
  48906. * @param lodOffset defines offset to apply to the mip map selection
  48907. * @param onLoad defines an optional callback raised when the texture is loaded
  48908. * @param onError defines an optional callback raised if there is an issue to load the texture
  48909. * @param format defines the format of the data
  48910. * @param forcedExtension defines the extension to use to pick the right loader
  48911. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48912. * @returns the cube texture as an InternalTexture
  48913. */
  48914. 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;
  48915. }
  48916. }
  48917. declare module BABYLON {
  48918. /**
  48919. * Implementation of the DDS Texture Loader.
  48920. * @hidden
  48921. */
  48922. export class _DDSTextureLoader implements IInternalTextureLoader {
  48923. /**
  48924. * Defines wether the loader supports cascade loading the different faces.
  48925. */
  48926. readonly supportCascades: boolean;
  48927. /**
  48928. * This returns if the loader support the current file information.
  48929. * @param extension defines the file extension of the file being loaded
  48930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48931. * @param fallback defines the fallback internal texture if any
  48932. * @param isBase64 defines whether the texture is encoded as a base64
  48933. * @param isBuffer defines whether the texture data are stored as a buffer
  48934. * @returns true if the loader can load the specified file
  48935. */
  48936. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48937. /**
  48938. * Transform the url before loading if required.
  48939. * @param rootUrl the url of the texture
  48940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48941. * @returns the transformed texture
  48942. */
  48943. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48944. /**
  48945. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48946. * @param rootUrl the url of the texture
  48947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48948. * @returns the fallback texture
  48949. */
  48950. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48951. /**
  48952. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48953. * @param data contains the texture data
  48954. * @param texture defines the BabylonJS internal texture
  48955. * @param createPolynomials will be true if polynomials have been requested
  48956. * @param onLoad defines the callback to trigger once the texture is ready
  48957. * @param onError defines the callback to trigger in case of error
  48958. */
  48959. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48960. /**
  48961. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48962. * @param data contains the texture data
  48963. * @param texture defines the BabylonJS internal texture
  48964. * @param callback defines the method to call once ready to upload
  48965. */
  48966. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48967. }
  48968. }
  48969. declare module BABYLON {
  48970. /**
  48971. * Implementation of the ENV Texture Loader.
  48972. * @hidden
  48973. */
  48974. export class _ENVTextureLoader implements IInternalTextureLoader {
  48975. /**
  48976. * Defines wether the loader supports cascade loading the different faces.
  48977. */
  48978. readonly supportCascades: boolean;
  48979. /**
  48980. * This returns if the loader support the current file information.
  48981. * @param extension defines the file extension of the file being loaded
  48982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48983. * @param fallback defines the fallback internal texture if any
  48984. * @param isBase64 defines whether the texture is encoded as a base64
  48985. * @param isBuffer defines whether the texture data are stored as a buffer
  48986. * @returns true if the loader can load the specified file
  48987. */
  48988. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48989. /**
  48990. * Transform the url before loading if required.
  48991. * @param rootUrl the url of the texture
  48992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48993. * @returns the transformed texture
  48994. */
  48995. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48996. /**
  48997. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48998. * @param rootUrl the url of the texture
  48999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49000. * @returns the fallback texture
  49001. */
  49002. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49003. /**
  49004. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49005. * @param data contains the texture data
  49006. * @param texture defines the BabylonJS internal texture
  49007. * @param createPolynomials will be true if polynomials have been requested
  49008. * @param onLoad defines the callback to trigger once the texture is ready
  49009. * @param onError defines the callback to trigger in case of error
  49010. */
  49011. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49012. /**
  49013. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49014. * @param data contains the texture data
  49015. * @param texture defines the BabylonJS internal texture
  49016. * @param callback defines the method to call once ready to upload
  49017. */
  49018. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49019. }
  49020. }
  49021. declare module BABYLON {
  49022. /**
  49023. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49024. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49025. */
  49026. export class KhronosTextureContainer {
  49027. /** contents of the KTX container file */
  49028. arrayBuffer: any;
  49029. private static HEADER_LEN;
  49030. private static COMPRESSED_2D;
  49031. private static COMPRESSED_3D;
  49032. private static TEX_2D;
  49033. private static TEX_3D;
  49034. /**
  49035. * Gets the openGL type
  49036. */
  49037. glType: number;
  49038. /**
  49039. * Gets the openGL type size
  49040. */
  49041. glTypeSize: number;
  49042. /**
  49043. * Gets the openGL format
  49044. */
  49045. glFormat: number;
  49046. /**
  49047. * Gets the openGL internal format
  49048. */
  49049. glInternalFormat: number;
  49050. /**
  49051. * Gets the base internal format
  49052. */
  49053. glBaseInternalFormat: number;
  49054. /**
  49055. * Gets image width in pixel
  49056. */
  49057. pixelWidth: number;
  49058. /**
  49059. * Gets image height in pixel
  49060. */
  49061. pixelHeight: number;
  49062. /**
  49063. * Gets image depth in pixels
  49064. */
  49065. pixelDepth: number;
  49066. /**
  49067. * Gets the number of array elements
  49068. */
  49069. numberOfArrayElements: number;
  49070. /**
  49071. * Gets the number of faces
  49072. */
  49073. numberOfFaces: number;
  49074. /**
  49075. * Gets the number of mipmap levels
  49076. */
  49077. numberOfMipmapLevels: number;
  49078. /**
  49079. * Gets the bytes of key value data
  49080. */
  49081. bytesOfKeyValueData: number;
  49082. /**
  49083. * Gets the load type
  49084. */
  49085. loadType: number;
  49086. /**
  49087. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49088. */
  49089. isInvalid: boolean;
  49090. /**
  49091. * Creates a new KhronosTextureContainer
  49092. * @param arrayBuffer contents of the KTX container file
  49093. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49094. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49095. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49096. */
  49097. constructor(
  49098. /** contents of the KTX container file */
  49099. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49100. /**
  49101. * Uploads KTX content to a Babylon Texture.
  49102. * It is assumed that the texture has already been created & is currently bound
  49103. * @hidden
  49104. */
  49105. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49106. private _upload2DCompressedLevels;
  49107. }
  49108. }
  49109. declare module BABYLON {
  49110. /**
  49111. * Implementation of the KTX Texture Loader.
  49112. * @hidden
  49113. */
  49114. export class _KTXTextureLoader implements IInternalTextureLoader {
  49115. /**
  49116. * Defines wether the loader supports cascade loading the different faces.
  49117. */
  49118. readonly supportCascades: boolean;
  49119. /**
  49120. * This returns if the loader support the current file information.
  49121. * @param extension defines the file extension of the file being loaded
  49122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49123. * @param fallback defines the fallback internal texture if any
  49124. * @param isBase64 defines whether the texture is encoded as a base64
  49125. * @param isBuffer defines whether the texture data are stored as a buffer
  49126. * @returns true if the loader can load the specified file
  49127. */
  49128. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49129. /**
  49130. * Transform the url before loading if required.
  49131. * @param rootUrl the url of the texture
  49132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49133. * @returns the transformed texture
  49134. */
  49135. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49136. /**
  49137. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49138. * @param rootUrl the url of the texture
  49139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49140. * @returns the fallback texture
  49141. */
  49142. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49143. /**
  49144. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49145. * @param data contains the texture data
  49146. * @param texture defines the BabylonJS internal texture
  49147. * @param createPolynomials will be true if polynomials have been requested
  49148. * @param onLoad defines the callback to trigger once the texture is ready
  49149. * @param onError defines the callback to trigger in case of error
  49150. */
  49151. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49152. /**
  49153. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49154. * @param data contains the texture data
  49155. * @param texture defines the BabylonJS internal texture
  49156. * @param callback defines the method to call once ready to upload
  49157. */
  49158. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. /**
  49163. * Options for the default xr helper
  49164. */
  49165. export class WebXRDefaultExperienceOptions {
  49166. /**
  49167. * Floor meshes that should be used for teleporting
  49168. */
  49169. floorMeshes: Array<AbstractMesh>;
  49170. /**
  49171. * Enable or disable default UI to enter XR
  49172. */
  49173. disableDefaultUI: boolean;
  49174. }
  49175. /**
  49176. * Default experience which provides a similar setup to the previous webVRExperience
  49177. */
  49178. export class WebXRDefaultExperience {
  49179. /**
  49180. * Base experience
  49181. */
  49182. baseExperience: WebXRExperienceHelper;
  49183. /**
  49184. * Input experience extension
  49185. */
  49186. input: WebXRInput;
  49187. /**
  49188. * Loads the controller models
  49189. */
  49190. controllerModelLoader: WebXRControllerModelLoader;
  49191. /**
  49192. * Enables laser pointer and selection
  49193. */
  49194. pointerSelection: WebXRControllerPointerSelection;
  49195. /**
  49196. * Enables teleportation
  49197. */
  49198. teleportation: WebXRControllerTeleportation;
  49199. /**
  49200. * Enables ui for enetering/exiting xr
  49201. */
  49202. enterExitUI: WebXREnterExitUI;
  49203. /**
  49204. * Default target xr should render to
  49205. */
  49206. renderTarget: WebXRRenderTarget;
  49207. /**
  49208. * Creates the default xr experience
  49209. * @param scene scene
  49210. * @param options options for basic configuration
  49211. * @returns resulting WebXRDefaultExperience
  49212. */
  49213. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49214. private constructor();
  49215. /**
  49216. * DIsposes of the experience helper
  49217. */
  49218. dispose(): void;
  49219. }
  49220. }
  49221. declare module BABYLON {
  49222. /** @hidden */
  49223. export var _forceSceneHelpersToBundle: boolean;
  49224. interface Scene {
  49225. /**
  49226. * Creates a default light for the scene.
  49227. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49228. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49229. */
  49230. createDefaultLight(replace?: boolean): void;
  49231. /**
  49232. * Creates a default camera for the scene.
  49233. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49234. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49235. * @param replace has default false, when true replaces the active camera in the scene
  49236. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49237. */
  49238. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49239. /**
  49240. * Creates a default camera and a default light.
  49241. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49242. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49243. * @param replace has the default false, when true replaces the active camera/light in the scene
  49244. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49245. */
  49246. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49247. /**
  49248. * Creates a new sky box
  49249. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49250. * @param environmentTexture defines the texture to use as environment texture
  49251. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49252. * @param scale defines the overall scale of the skybox
  49253. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49254. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49255. * @returns a new mesh holding the sky box
  49256. */
  49257. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49258. /**
  49259. * Creates a new environment
  49260. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49261. * @param options defines the options you can use to configure the environment
  49262. * @returns the new EnvironmentHelper
  49263. */
  49264. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49265. /**
  49266. * Creates a new VREXperienceHelper
  49267. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49268. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49269. * @returns a new VREXperienceHelper
  49270. */
  49271. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49272. /**
  49273. * Creates a new WebXRDefaultExperience
  49274. * @see http://doc.babylonjs.com/how_to/webxr
  49275. * @param options experience options
  49276. * @returns a promise for a new WebXRDefaultExperience
  49277. */
  49278. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49279. }
  49280. }
  49281. declare module BABYLON {
  49282. /**
  49283. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49284. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49285. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49286. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49287. */
  49288. export class VideoDome extends TransformNode {
  49289. /**
  49290. * Define the video source as a Monoscopic panoramic 360 video.
  49291. */
  49292. static readonly MODE_MONOSCOPIC: number;
  49293. /**
  49294. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49295. */
  49296. static readonly MODE_TOPBOTTOM: number;
  49297. /**
  49298. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49299. */
  49300. static readonly MODE_SIDEBYSIDE: number;
  49301. private _halfDome;
  49302. private _useDirectMapping;
  49303. /**
  49304. * The video texture being displayed on the sphere
  49305. */
  49306. protected _videoTexture: VideoTexture;
  49307. /**
  49308. * Gets the video texture being displayed on the sphere
  49309. */
  49310. readonly videoTexture: VideoTexture;
  49311. /**
  49312. * The skybox material
  49313. */
  49314. protected _material: BackgroundMaterial;
  49315. /**
  49316. * The surface used for the skybox
  49317. */
  49318. protected _mesh: Mesh;
  49319. /**
  49320. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49321. */
  49322. private _halfDomeMask;
  49323. /**
  49324. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49325. * Also see the options.resolution property.
  49326. */
  49327. fovMultiplier: number;
  49328. private _videoMode;
  49329. /**
  49330. * Gets or set the current video mode for the video. It can be:
  49331. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49332. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49333. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49334. */
  49335. videoMode: number;
  49336. /**
  49337. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49338. *
  49339. */
  49340. /**
  49341. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49342. */
  49343. halfDome: boolean;
  49344. /**
  49345. * Oberserver used in Stereoscopic VR Mode.
  49346. */
  49347. private _onBeforeCameraRenderObserver;
  49348. /**
  49349. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49350. * @param name Element's name, child elements will append suffixes for their own names.
  49351. * @param urlsOrVideo defines the url(s) or the video element to use
  49352. * @param options An object containing optional or exposed sub element properties
  49353. */
  49354. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49355. resolution?: number;
  49356. clickToPlay?: boolean;
  49357. autoPlay?: boolean;
  49358. loop?: boolean;
  49359. size?: number;
  49360. poster?: string;
  49361. faceForward?: boolean;
  49362. useDirectMapping?: boolean;
  49363. halfDomeMode?: boolean;
  49364. }, scene: Scene);
  49365. private _changeVideoMode;
  49366. /**
  49367. * Releases resources associated with this node.
  49368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49370. */
  49371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49372. }
  49373. }
  49374. declare module BABYLON {
  49375. /**
  49376. * This class can be used to get instrumentation data from a Babylon engine
  49377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49378. */
  49379. export class EngineInstrumentation implements IDisposable {
  49380. /**
  49381. * Define the instrumented engine.
  49382. */
  49383. engine: Engine;
  49384. private _captureGPUFrameTime;
  49385. private _gpuFrameTimeToken;
  49386. private _gpuFrameTime;
  49387. private _captureShaderCompilationTime;
  49388. private _shaderCompilationTime;
  49389. private _onBeginFrameObserver;
  49390. private _onEndFrameObserver;
  49391. private _onBeforeShaderCompilationObserver;
  49392. private _onAfterShaderCompilationObserver;
  49393. /**
  49394. * Gets the perf counter used for GPU frame time
  49395. */
  49396. readonly gpuFrameTimeCounter: PerfCounter;
  49397. /**
  49398. * Gets the GPU frame time capture status
  49399. */
  49400. /**
  49401. * Enable or disable the GPU frame time capture
  49402. */
  49403. captureGPUFrameTime: boolean;
  49404. /**
  49405. * Gets the perf counter used for shader compilation time
  49406. */
  49407. readonly shaderCompilationTimeCounter: PerfCounter;
  49408. /**
  49409. * Gets the shader compilation time capture status
  49410. */
  49411. /**
  49412. * Enable or disable the shader compilation time capture
  49413. */
  49414. captureShaderCompilationTime: boolean;
  49415. /**
  49416. * Instantiates a new engine instrumentation.
  49417. * This class can be used to get instrumentation data from a Babylon engine
  49418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49419. * @param engine Defines the engine to instrument
  49420. */
  49421. constructor(
  49422. /**
  49423. * Define the instrumented engine.
  49424. */
  49425. engine: Engine);
  49426. /**
  49427. * Dispose and release associated resources.
  49428. */
  49429. dispose(): void;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * This class can be used to get instrumentation data from a Babylon engine
  49435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49436. */
  49437. export class SceneInstrumentation implements IDisposable {
  49438. /**
  49439. * Defines the scene to instrument
  49440. */
  49441. scene: Scene;
  49442. private _captureActiveMeshesEvaluationTime;
  49443. private _activeMeshesEvaluationTime;
  49444. private _captureRenderTargetsRenderTime;
  49445. private _renderTargetsRenderTime;
  49446. private _captureFrameTime;
  49447. private _frameTime;
  49448. private _captureRenderTime;
  49449. private _renderTime;
  49450. private _captureInterFrameTime;
  49451. private _interFrameTime;
  49452. private _captureParticlesRenderTime;
  49453. private _particlesRenderTime;
  49454. private _captureSpritesRenderTime;
  49455. private _spritesRenderTime;
  49456. private _capturePhysicsTime;
  49457. private _physicsTime;
  49458. private _captureAnimationsTime;
  49459. private _animationsTime;
  49460. private _captureCameraRenderTime;
  49461. private _cameraRenderTime;
  49462. private _onBeforeActiveMeshesEvaluationObserver;
  49463. private _onAfterActiveMeshesEvaluationObserver;
  49464. private _onBeforeRenderTargetsRenderObserver;
  49465. private _onAfterRenderTargetsRenderObserver;
  49466. private _onAfterRenderObserver;
  49467. private _onBeforeDrawPhaseObserver;
  49468. private _onAfterDrawPhaseObserver;
  49469. private _onBeforeAnimationsObserver;
  49470. private _onBeforeParticlesRenderingObserver;
  49471. private _onAfterParticlesRenderingObserver;
  49472. private _onBeforeSpritesRenderingObserver;
  49473. private _onAfterSpritesRenderingObserver;
  49474. private _onBeforePhysicsObserver;
  49475. private _onAfterPhysicsObserver;
  49476. private _onAfterAnimationsObserver;
  49477. private _onBeforeCameraRenderObserver;
  49478. private _onAfterCameraRenderObserver;
  49479. /**
  49480. * Gets the perf counter used for active meshes evaluation time
  49481. */
  49482. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49483. /**
  49484. * Gets the active meshes evaluation time capture status
  49485. */
  49486. /**
  49487. * Enable or disable the active meshes evaluation time capture
  49488. */
  49489. captureActiveMeshesEvaluationTime: boolean;
  49490. /**
  49491. * Gets the perf counter used for render targets render time
  49492. */
  49493. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49494. /**
  49495. * Gets the render targets render time capture status
  49496. */
  49497. /**
  49498. * Enable or disable the render targets render time capture
  49499. */
  49500. captureRenderTargetsRenderTime: boolean;
  49501. /**
  49502. * Gets the perf counter used for particles render time
  49503. */
  49504. readonly particlesRenderTimeCounter: PerfCounter;
  49505. /**
  49506. * Gets the particles render time capture status
  49507. */
  49508. /**
  49509. * Enable or disable the particles render time capture
  49510. */
  49511. captureParticlesRenderTime: boolean;
  49512. /**
  49513. * Gets the perf counter used for sprites render time
  49514. */
  49515. readonly spritesRenderTimeCounter: PerfCounter;
  49516. /**
  49517. * Gets the sprites render time capture status
  49518. */
  49519. /**
  49520. * Enable or disable the sprites render time capture
  49521. */
  49522. captureSpritesRenderTime: boolean;
  49523. /**
  49524. * Gets the perf counter used for physics time
  49525. */
  49526. readonly physicsTimeCounter: PerfCounter;
  49527. /**
  49528. * Gets the physics time capture status
  49529. */
  49530. /**
  49531. * Enable or disable the physics time capture
  49532. */
  49533. capturePhysicsTime: boolean;
  49534. /**
  49535. * Gets the perf counter used for animations time
  49536. */
  49537. readonly animationsTimeCounter: PerfCounter;
  49538. /**
  49539. * Gets the animations time capture status
  49540. */
  49541. /**
  49542. * Enable or disable the animations time capture
  49543. */
  49544. captureAnimationsTime: boolean;
  49545. /**
  49546. * Gets the perf counter used for frame time capture
  49547. */
  49548. readonly frameTimeCounter: PerfCounter;
  49549. /**
  49550. * Gets the frame time capture status
  49551. */
  49552. /**
  49553. * Enable or disable the frame time capture
  49554. */
  49555. captureFrameTime: boolean;
  49556. /**
  49557. * Gets the perf counter used for inter-frames time capture
  49558. */
  49559. readonly interFrameTimeCounter: PerfCounter;
  49560. /**
  49561. * Gets the inter-frames time capture status
  49562. */
  49563. /**
  49564. * Enable or disable the inter-frames time capture
  49565. */
  49566. captureInterFrameTime: boolean;
  49567. /**
  49568. * Gets the perf counter used for render time capture
  49569. */
  49570. readonly renderTimeCounter: PerfCounter;
  49571. /**
  49572. * Gets the render time capture status
  49573. */
  49574. /**
  49575. * Enable or disable the render time capture
  49576. */
  49577. captureRenderTime: boolean;
  49578. /**
  49579. * Gets the perf counter used for camera render time capture
  49580. */
  49581. readonly cameraRenderTimeCounter: PerfCounter;
  49582. /**
  49583. * Gets the camera render time capture status
  49584. */
  49585. /**
  49586. * Enable or disable the camera render time capture
  49587. */
  49588. captureCameraRenderTime: boolean;
  49589. /**
  49590. * Gets the perf counter used for draw calls
  49591. */
  49592. readonly drawCallsCounter: PerfCounter;
  49593. /**
  49594. * Instantiates a new scene instrumentation.
  49595. * This class can be used to get instrumentation data from a Babylon engine
  49596. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49597. * @param scene Defines the scene to instrument
  49598. */
  49599. constructor(
  49600. /**
  49601. * Defines the scene to instrument
  49602. */
  49603. scene: Scene);
  49604. /**
  49605. * Dispose and release associated resources.
  49606. */
  49607. dispose(): void;
  49608. }
  49609. }
  49610. declare module BABYLON {
  49611. /** @hidden */
  49612. export var glowMapGenerationPixelShader: {
  49613. name: string;
  49614. shader: string;
  49615. };
  49616. }
  49617. declare module BABYLON {
  49618. /** @hidden */
  49619. export var glowMapGenerationVertexShader: {
  49620. name: string;
  49621. shader: string;
  49622. };
  49623. }
  49624. declare module BABYLON {
  49625. /**
  49626. * Effect layer options. This helps customizing the behaviour
  49627. * of the effect layer.
  49628. */
  49629. export interface IEffectLayerOptions {
  49630. /**
  49631. * Multiplication factor apply to the canvas size to compute the render target size
  49632. * used to generated the objects (the smaller the faster).
  49633. */
  49634. mainTextureRatio: number;
  49635. /**
  49636. * Enforces a fixed size texture to ensure effect stability across devices.
  49637. */
  49638. mainTextureFixedSize?: number;
  49639. /**
  49640. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49641. */
  49642. alphaBlendingMode: number;
  49643. /**
  49644. * The camera attached to the layer.
  49645. */
  49646. camera: Nullable<Camera>;
  49647. /**
  49648. * The rendering group to draw the layer in.
  49649. */
  49650. renderingGroupId: number;
  49651. }
  49652. /**
  49653. * The effect layer Helps adding post process effect blended with the main pass.
  49654. *
  49655. * This can be for instance use to generate glow or higlight effects on the scene.
  49656. *
  49657. * The effect layer class can not be used directly and is intented to inherited from to be
  49658. * customized per effects.
  49659. */
  49660. export abstract class EffectLayer {
  49661. private _vertexBuffers;
  49662. private _indexBuffer;
  49663. private _cachedDefines;
  49664. private _effectLayerMapGenerationEffect;
  49665. private _effectLayerOptions;
  49666. private _mergeEffect;
  49667. protected _scene: Scene;
  49668. protected _engine: Engine;
  49669. protected _maxSize: number;
  49670. protected _mainTextureDesiredSize: ISize;
  49671. protected _mainTexture: RenderTargetTexture;
  49672. protected _shouldRender: boolean;
  49673. protected _postProcesses: PostProcess[];
  49674. protected _textures: BaseTexture[];
  49675. protected _emissiveTextureAndColor: {
  49676. texture: Nullable<BaseTexture>;
  49677. color: Color4;
  49678. };
  49679. /**
  49680. * The name of the layer
  49681. */
  49682. name: string;
  49683. /**
  49684. * The clear color of the texture used to generate the glow map.
  49685. */
  49686. neutralColor: Color4;
  49687. /**
  49688. * Specifies wether the highlight layer is enabled or not.
  49689. */
  49690. isEnabled: boolean;
  49691. /**
  49692. * Gets the camera attached to the layer.
  49693. */
  49694. readonly camera: Nullable<Camera>;
  49695. /**
  49696. * Gets the rendering group id the layer should render in.
  49697. */
  49698. renderingGroupId: number;
  49699. /**
  49700. * An event triggered when the effect layer has been disposed.
  49701. */
  49702. onDisposeObservable: Observable<EffectLayer>;
  49703. /**
  49704. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49705. */
  49706. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49707. /**
  49708. * An event triggered when the generated texture is being merged in the scene.
  49709. */
  49710. onBeforeComposeObservable: Observable<EffectLayer>;
  49711. /**
  49712. * An event triggered when the mesh is rendered into the effect render target.
  49713. */
  49714. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  49715. /**
  49716. * An event triggered after the mesh has been rendered into the effect render target.
  49717. */
  49718. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  49719. /**
  49720. * An event triggered when the generated texture has been merged in the scene.
  49721. */
  49722. onAfterComposeObservable: Observable<EffectLayer>;
  49723. /**
  49724. * An event triggered when the efffect layer changes its size.
  49725. */
  49726. onSizeChangedObservable: Observable<EffectLayer>;
  49727. /** @hidden */
  49728. static _SceneComponentInitialization: (scene: Scene) => void;
  49729. /**
  49730. * Instantiates a new effect Layer and references it in the scene.
  49731. * @param name The name of the layer
  49732. * @param scene The scene to use the layer in
  49733. */
  49734. constructor(
  49735. /** The Friendly of the effect in the scene */
  49736. name: string, scene: Scene);
  49737. /**
  49738. * Get the effect name of the layer.
  49739. * @return The effect name
  49740. */
  49741. abstract getEffectName(): string;
  49742. /**
  49743. * Checks for the readiness of the element composing the layer.
  49744. * @param subMesh the mesh to check for
  49745. * @param useInstances specify wether or not to use instances to render the mesh
  49746. * @return true if ready otherwise, false
  49747. */
  49748. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49749. /**
  49750. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49751. * @returns true if the effect requires stencil during the main canvas render pass.
  49752. */
  49753. abstract needStencil(): boolean;
  49754. /**
  49755. * Create the merge effect. This is the shader use to blit the information back
  49756. * to the main canvas at the end of the scene rendering.
  49757. * @returns The effect containing the shader used to merge the effect on the main canvas
  49758. */
  49759. protected abstract _createMergeEffect(): Effect;
  49760. /**
  49761. * Creates the render target textures and post processes used in the effect layer.
  49762. */
  49763. protected abstract _createTextureAndPostProcesses(): void;
  49764. /**
  49765. * Implementation specific of rendering the generating effect on the main canvas.
  49766. * @param effect The effect used to render through
  49767. */
  49768. protected abstract _internalRender(effect: Effect): void;
  49769. /**
  49770. * Sets the required values for both the emissive texture and and the main color.
  49771. */
  49772. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49773. /**
  49774. * Free any resources and references associated to a mesh.
  49775. * Internal use
  49776. * @param mesh The mesh to free.
  49777. */
  49778. abstract _disposeMesh(mesh: Mesh): void;
  49779. /**
  49780. * Serializes this layer (Glow or Highlight for example)
  49781. * @returns a serialized layer object
  49782. */
  49783. abstract serialize?(): any;
  49784. /**
  49785. * Initializes the effect layer with the required options.
  49786. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49787. */
  49788. protected _init(options: Partial<IEffectLayerOptions>): void;
  49789. /**
  49790. * Generates the index buffer of the full screen quad blending to the main canvas.
  49791. */
  49792. private _generateIndexBuffer;
  49793. /**
  49794. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49795. */
  49796. private _generateVertexBuffer;
  49797. /**
  49798. * Sets the main texture desired size which is the closest power of two
  49799. * of the engine canvas size.
  49800. */
  49801. private _setMainTextureSize;
  49802. /**
  49803. * Creates the main texture for the effect layer.
  49804. */
  49805. protected _createMainTexture(): void;
  49806. /**
  49807. * Adds specific effects defines.
  49808. * @param defines The defines to add specifics to.
  49809. */
  49810. protected _addCustomEffectDefines(defines: string[]): void;
  49811. /**
  49812. * Checks for the readiness of the element composing the layer.
  49813. * @param subMesh the mesh to check for
  49814. * @param useInstances specify wether or not to use instances to render the mesh
  49815. * @param emissiveTexture the associated emissive texture used to generate the glow
  49816. * @return true if ready otherwise, false
  49817. */
  49818. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49819. /**
  49820. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49821. */
  49822. render(): void;
  49823. /**
  49824. * Determine if a given mesh will be used in the current effect.
  49825. * @param mesh mesh to test
  49826. * @returns true if the mesh will be used
  49827. */
  49828. hasMesh(mesh: AbstractMesh): boolean;
  49829. /**
  49830. * Returns true if the layer contains information to display, otherwise false.
  49831. * @returns true if the glow layer should be rendered
  49832. */
  49833. shouldRender(): boolean;
  49834. /**
  49835. * Returns true if the mesh should render, otherwise false.
  49836. * @param mesh The mesh to render
  49837. * @returns true if it should render otherwise false
  49838. */
  49839. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49840. /**
  49841. * Returns true if the mesh can be rendered, otherwise false.
  49842. * @param mesh The mesh to render
  49843. * @param material The material used on the mesh
  49844. * @returns true if it can be rendered otherwise false
  49845. */
  49846. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49847. /**
  49848. * Returns true if the mesh should render, otherwise false.
  49849. * @param mesh The mesh to render
  49850. * @returns true if it should render otherwise false
  49851. */
  49852. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49853. /**
  49854. * Renders the submesh passed in parameter to the generation map.
  49855. */
  49856. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49857. /**
  49858. * Defines wether the current material of the mesh should be use to render the effect.
  49859. * @param mesh defines the current mesh to render
  49860. */
  49861. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  49862. /**
  49863. * Rebuild the required buffers.
  49864. * @hidden Internal use only.
  49865. */
  49866. _rebuild(): void;
  49867. /**
  49868. * Dispose only the render target textures and post process.
  49869. */
  49870. private _disposeTextureAndPostProcesses;
  49871. /**
  49872. * Dispose the highlight layer and free resources.
  49873. */
  49874. dispose(): void;
  49875. /**
  49876. * Gets the class name of the effect layer
  49877. * @returns the string with the class name of the effect layer
  49878. */
  49879. getClassName(): string;
  49880. /**
  49881. * Creates an effect layer from parsed effect layer data
  49882. * @param parsedEffectLayer defines effect layer data
  49883. * @param scene defines the current scene
  49884. * @param rootUrl defines the root URL containing the effect layer information
  49885. * @returns a parsed effect Layer
  49886. */
  49887. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49888. }
  49889. }
  49890. declare module BABYLON {
  49891. interface AbstractScene {
  49892. /**
  49893. * The list of effect layers (highlights/glow) added to the scene
  49894. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49895. * @see http://doc.babylonjs.com/how_to/glow_layer
  49896. */
  49897. effectLayers: Array<EffectLayer>;
  49898. /**
  49899. * Removes the given effect layer from this scene.
  49900. * @param toRemove defines the effect layer to remove
  49901. * @returns the index of the removed effect layer
  49902. */
  49903. removeEffectLayer(toRemove: EffectLayer): number;
  49904. /**
  49905. * Adds the given effect layer to this scene
  49906. * @param newEffectLayer defines the effect layer to add
  49907. */
  49908. addEffectLayer(newEffectLayer: EffectLayer): void;
  49909. }
  49910. /**
  49911. * Defines the layer scene component responsible to manage any effect layers
  49912. * in a given scene.
  49913. */
  49914. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49915. /**
  49916. * The component name helpfull to identify the component in the list of scene components.
  49917. */
  49918. readonly name: string;
  49919. /**
  49920. * The scene the component belongs to.
  49921. */
  49922. scene: Scene;
  49923. private _engine;
  49924. private _renderEffects;
  49925. private _needStencil;
  49926. private _previousStencilState;
  49927. /**
  49928. * Creates a new instance of the component for the given scene
  49929. * @param scene Defines the scene to register the component in
  49930. */
  49931. constructor(scene: Scene);
  49932. /**
  49933. * Registers the component in a given scene
  49934. */
  49935. register(): void;
  49936. /**
  49937. * Rebuilds the elements related to this component in case of
  49938. * context lost for instance.
  49939. */
  49940. rebuild(): void;
  49941. /**
  49942. * Serializes the component data to the specified json object
  49943. * @param serializationObject The object to serialize to
  49944. */
  49945. serialize(serializationObject: any): void;
  49946. /**
  49947. * Adds all the elements from the container to the scene
  49948. * @param container the container holding the elements
  49949. */
  49950. addFromContainer(container: AbstractScene): void;
  49951. /**
  49952. * Removes all the elements in the container from the scene
  49953. * @param container contains the elements to remove
  49954. * @param dispose if the removed element should be disposed (default: false)
  49955. */
  49956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49957. /**
  49958. * Disposes the component and the associated ressources.
  49959. */
  49960. dispose(): void;
  49961. private _isReadyForMesh;
  49962. private _renderMainTexture;
  49963. private _setStencil;
  49964. private _setStencilBack;
  49965. private _draw;
  49966. private _drawCamera;
  49967. private _drawRenderingGroup;
  49968. }
  49969. }
  49970. declare module BABYLON {
  49971. /** @hidden */
  49972. export var glowMapMergePixelShader: {
  49973. name: string;
  49974. shader: string;
  49975. };
  49976. }
  49977. declare module BABYLON {
  49978. /** @hidden */
  49979. export var glowMapMergeVertexShader: {
  49980. name: string;
  49981. shader: string;
  49982. };
  49983. }
  49984. declare module BABYLON {
  49985. interface AbstractScene {
  49986. /**
  49987. * Return a the first highlight layer of the scene with a given name.
  49988. * @param name The name of the highlight layer to look for.
  49989. * @return The highlight layer if found otherwise null.
  49990. */
  49991. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49992. }
  49993. /**
  49994. * Glow layer options. This helps customizing the behaviour
  49995. * of the glow layer.
  49996. */
  49997. export interface IGlowLayerOptions {
  49998. /**
  49999. * Multiplication factor apply to the canvas size to compute the render target size
  50000. * used to generated the glowing objects (the smaller the faster).
  50001. */
  50002. mainTextureRatio: number;
  50003. /**
  50004. * Enforces a fixed size texture to ensure resize independant blur.
  50005. */
  50006. mainTextureFixedSize?: number;
  50007. /**
  50008. * How big is the kernel of the blur texture.
  50009. */
  50010. blurKernelSize: number;
  50011. /**
  50012. * The camera attached to the layer.
  50013. */
  50014. camera: Nullable<Camera>;
  50015. /**
  50016. * Enable MSAA by chosing the number of samples.
  50017. */
  50018. mainTextureSamples?: number;
  50019. /**
  50020. * The rendering group to draw the layer in.
  50021. */
  50022. renderingGroupId: number;
  50023. }
  50024. /**
  50025. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50026. *
  50027. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50028. *
  50029. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50030. */
  50031. export class GlowLayer extends EffectLayer {
  50032. /**
  50033. * Effect Name of the layer.
  50034. */
  50035. static readonly EffectName: string;
  50036. /**
  50037. * The default blur kernel size used for the glow.
  50038. */
  50039. static DefaultBlurKernelSize: number;
  50040. /**
  50041. * The default texture size ratio used for the glow.
  50042. */
  50043. static DefaultTextureRatio: number;
  50044. /**
  50045. * Sets the kernel size of the blur.
  50046. */
  50047. /**
  50048. * Gets the kernel size of the blur.
  50049. */
  50050. blurKernelSize: number;
  50051. /**
  50052. * Sets the glow intensity.
  50053. */
  50054. /**
  50055. * Gets the glow intensity.
  50056. */
  50057. intensity: number;
  50058. private _options;
  50059. private _intensity;
  50060. private _horizontalBlurPostprocess1;
  50061. private _verticalBlurPostprocess1;
  50062. private _horizontalBlurPostprocess2;
  50063. private _verticalBlurPostprocess2;
  50064. private _blurTexture1;
  50065. private _blurTexture2;
  50066. private _postProcesses1;
  50067. private _postProcesses2;
  50068. private _includedOnlyMeshes;
  50069. private _excludedMeshes;
  50070. private _meshesUsingTheirOwnMaterials;
  50071. /**
  50072. * Callback used to let the user override the color selection on a per mesh basis
  50073. */
  50074. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50075. /**
  50076. * Callback used to let the user override the texture selection on a per mesh basis
  50077. */
  50078. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50079. /**
  50080. * Instantiates a new glow Layer and references it to the scene.
  50081. * @param name The name of the layer
  50082. * @param scene The scene to use the layer in
  50083. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50084. */
  50085. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50086. /**
  50087. * Get the effect name of the layer.
  50088. * @return The effect name
  50089. */
  50090. getEffectName(): string;
  50091. /**
  50092. * Create the merge effect. This is the shader use to blit the information back
  50093. * to the main canvas at the end of the scene rendering.
  50094. */
  50095. protected _createMergeEffect(): Effect;
  50096. /**
  50097. * Creates the render target textures and post processes used in the glow layer.
  50098. */
  50099. protected _createTextureAndPostProcesses(): void;
  50100. /**
  50101. * Checks for the readiness of the element composing the layer.
  50102. * @param subMesh the mesh to check for
  50103. * @param useInstances specify wether or not to use instances to render the mesh
  50104. * @param emissiveTexture the associated emissive texture used to generate the glow
  50105. * @return true if ready otherwise, false
  50106. */
  50107. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50108. /**
  50109. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50110. */
  50111. needStencil(): boolean;
  50112. /**
  50113. * Returns true if the mesh can be rendered, otherwise false.
  50114. * @param mesh The mesh to render
  50115. * @param material The material used on the mesh
  50116. * @returns true if it can be rendered otherwise false
  50117. */
  50118. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50119. /**
  50120. * Implementation specific of rendering the generating effect on the main canvas.
  50121. * @param effect The effect used to render through
  50122. */
  50123. protected _internalRender(effect: Effect): void;
  50124. /**
  50125. * Sets the required values for both the emissive texture and and the main color.
  50126. */
  50127. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50128. /**
  50129. * Returns true if the mesh should render, otherwise false.
  50130. * @param mesh The mesh to render
  50131. * @returns true if it should render otherwise false
  50132. */
  50133. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50134. /**
  50135. * Adds specific effects defines.
  50136. * @param defines The defines to add specifics to.
  50137. */
  50138. protected _addCustomEffectDefines(defines: string[]): void;
  50139. /**
  50140. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50141. * @param mesh The mesh to exclude from the glow layer
  50142. */
  50143. addExcludedMesh(mesh: Mesh): void;
  50144. /**
  50145. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50146. * @param mesh The mesh to remove
  50147. */
  50148. removeExcludedMesh(mesh: Mesh): void;
  50149. /**
  50150. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50151. * @param mesh The mesh to include in the glow layer
  50152. */
  50153. addIncludedOnlyMesh(mesh: Mesh): void;
  50154. /**
  50155. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50156. * @param mesh The mesh to remove
  50157. */
  50158. removeIncludedOnlyMesh(mesh: Mesh): void;
  50159. /**
  50160. * Determine if a given mesh will be used in the glow layer
  50161. * @param mesh The mesh to test
  50162. * @returns true if the mesh will be highlighted by the current glow layer
  50163. */
  50164. hasMesh(mesh: AbstractMesh): boolean;
  50165. /**
  50166. * Defines wether the current material of the mesh should be use to render the effect.
  50167. * @param mesh defines the current mesh to render
  50168. */
  50169. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50170. /**
  50171. * Add a mesh to be rendered through its own material and not with emissive only.
  50172. * @param mesh The mesh for which we need to use its material
  50173. */
  50174. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50175. /**
  50176. * Remove a mesh from being rendered through its own material and not with emissive only.
  50177. * @param mesh The mesh for which we need to not use its material
  50178. */
  50179. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50180. /**
  50181. * Free any resources and references associated to a mesh.
  50182. * Internal use
  50183. * @param mesh The mesh to free.
  50184. * @hidden
  50185. */
  50186. _disposeMesh(mesh: Mesh): void;
  50187. /**
  50188. * Gets the class name of the effect layer
  50189. * @returns the string with the class name of the effect layer
  50190. */
  50191. getClassName(): string;
  50192. /**
  50193. * Serializes this glow layer
  50194. * @returns a serialized glow layer object
  50195. */
  50196. serialize(): any;
  50197. /**
  50198. * Creates a Glow Layer from parsed glow layer data
  50199. * @param parsedGlowLayer defines glow layer data
  50200. * @param scene defines the current scene
  50201. * @param rootUrl defines the root URL containing the glow layer information
  50202. * @returns a parsed Glow Layer
  50203. */
  50204. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50205. }
  50206. }
  50207. declare module BABYLON {
  50208. /** @hidden */
  50209. export var glowBlurPostProcessPixelShader: {
  50210. name: string;
  50211. shader: string;
  50212. };
  50213. }
  50214. declare module BABYLON {
  50215. interface AbstractScene {
  50216. /**
  50217. * Return a the first highlight layer of the scene with a given name.
  50218. * @param name The name of the highlight layer to look for.
  50219. * @return The highlight layer if found otherwise null.
  50220. */
  50221. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50222. }
  50223. /**
  50224. * Highlight layer options. This helps customizing the behaviour
  50225. * of the highlight layer.
  50226. */
  50227. export interface IHighlightLayerOptions {
  50228. /**
  50229. * Multiplication factor apply to the canvas size to compute the render target size
  50230. * used to generated the glowing objects (the smaller the faster).
  50231. */
  50232. mainTextureRatio: number;
  50233. /**
  50234. * Enforces a fixed size texture to ensure resize independant blur.
  50235. */
  50236. mainTextureFixedSize?: number;
  50237. /**
  50238. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50239. * of the picture to blur (the smaller the faster).
  50240. */
  50241. blurTextureSizeRatio: number;
  50242. /**
  50243. * How big in texel of the blur texture is the vertical blur.
  50244. */
  50245. blurVerticalSize: number;
  50246. /**
  50247. * How big in texel of the blur texture is the horizontal blur.
  50248. */
  50249. blurHorizontalSize: number;
  50250. /**
  50251. * Alpha blending mode used to apply the blur. Default is combine.
  50252. */
  50253. alphaBlendingMode: number;
  50254. /**
  50255. * The camera attached to the layer.
  50256. */
  50257. camera: Nullable<Camera>;
  50258. /**
  50259. * Should we display highlight as a solid stroke?
  50260. */
  50261. isStroke?: boolean;
  50262. /**
  50263. * The rendering group to draw the layer in.
  50264. */
  50265. renderingGroupId: number;
  50266. }
  50267. /**
  50268. * The highlight layer Helps adding a glow effect around a mesh.
  50269. *
  50270. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50271. * glowy meshes to your scene.
  50272. *
  50273. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50274. */
  50275. export class HighlightLayer extends EffectLayer {
  50276. name: string;
  50277. /**
  50278. * Effect Name of the highlight layer.
  50279. */
  50280. static readonly EffectName: string;
  50281. /**
  50282. * The neutral color used during the preparation of the glow effect.
  50283. * This is black by default as the blend operation is a blend operation.
  50284. */
  50285. static NeutralColor: Color4;
  50286. /**
  50287. * Stencil value used for glowing meshes.
  50288. */
  50289. static GlowingMeshStencilReference: number;
  50290. /**
  50291. * Stencil value used for the other meshes in the scene.
  50292. */
  50293. static NormalMeshStencilReference: number;
  50294. /**
  50295. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50296. */
  50297. innerGlow: boolean;
  50298. /**
  50299. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50300. */
  50301. outerGlow: boolean;
  50302. /**
  50303. * Specifies the horizontal size of the blur.
  50304. */
  50305. /**
  50306. * Gets the horizontal size of the blur.
  50307. */
  50308. blurHorizontalSize: number;
  50309. /**
  50310. * Specifies the vertical size of the blur.
  50311. */
  50312. /**
  50313. * Gets the vertical size of the blur.
  50314. */
  50315. blurVerticalSize: number;
  50316. /**
  50317. * An event triggered when the highlight layer is being blurred.
  50318. */
  50319. onBeforeBlurObservable: Observable<HighlightLayer>;
  50320. /**
  50321. * An event triggered when the highlight layer has been blurred.
  50322. */
  50323. onAfterBlurObservable: Observable<HighlightLayer>;
  50324. private _instanceGlowingMeshStencilReference;
  50325. private _options;
  50326. private _downSamplePostprocess;
  50327. private _horizontalBlurPostprocess;
  50328. private _verticalBlurPostprocess;
  50329. private _blurTexture;
  50330. private _meshes;
  50331. private _excludedMeshes;
  50332. /**
  50333. * Instantiates a new highlight Layer and references it to the scene..
  50334. * @param name The name of the layer
  50335. * @param scene The scene to use the layer in
  50336. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50337. */
  50338. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50339. /**
  50340. * Get the effect name of the layer.
  50341. * @return The effect name
  50342. */
  50343. getEffectName(): string;
  50344. /**
  50345. * Create the merge effect. This is the shader use to blit the information back
  50346. * to the main canvas at the end of the scene rendering.
  50347. */
  50348. protected _createMergeEffect(): Effect;
  50349. /**
  50350. * Creates the render target textures and post processes used in the highlight layer.
  50351. */
  50352. protected _createTextureAndPostProcesses(): void;
  50353. /**
  50354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50355. */
  50356. needStencil(): boolean;
  50357. /**
  50358. * Checks for the readiness of the element composing the layer.
  50359. * @param subMesh the mesh to check for
  50360. * @param useInstances specify wether or not to use instances to render the mesh
  50361. * @param emissiveTexture the associated emissive texture used to generate the glow
  50362. * @return true if ready otherwise, false
  50363. */
  50364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50365. /**
  50366. * Implementation specific of rendering the generating effect on the main canvas.
  50367. * @param effect The effect used to render through
  50368. */
  50369. protected _internalRender(effect: Effect): void;
  50370. /**
  50371. * Returns true if the layer contains information to display, otherwise false.
  50372. */
  50373. shouldRender(): boolean;
  50374. /**
  50375. * Returns true if the mesh should render, otherwise false.
  50376. * @param mesh The mesh to render
  50377. * @returns true if it should render otherwise false
  50378. */
  50379. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50380. /**
  50381. * Sets the required values for both the emissive texture and and the main color.
  50382. */
  50383. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50384. /**
  50385. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50386. * @param mesh The mesh to exclude from the highlight layer
  50387. */
  50388. addExcludedMesh(mesh: Mesh): void;
  50389. /**
  50390. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50391. * @param mesh The mesh to highlight
  50392. */
  50393. removeExcludedMesh(mesh: Mesh): void;
  50394. /**
  50395. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50396. * @param mesh mesh to test
  50397. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50398. */
  50399. hasMesh(mesh: AbstractMesh): boolean;
  50400. /**
  50401. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50402. * @param mesh The mesh to highlight
  50403. * @param color The color of the highlight
  50404. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50405. */
  50406. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50407. /**
  50408. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50409. * @param mesh The mesh to highlight
  50410. */
  50411. removeMesh(mesh: Mesh): void;
  50412. /**
  50413. * Force the stencil to the normal expected value for none glowing parts
  50414. */
  50415. private _defaultStencilReference;
  50416. /**
  50417. * Free any resources and references associated to a mesh.
  50418. * Internal use
  50419. * @param mesh The mesh to free.
  50420. * @hidden
  50421. */
  50422. _disposeMesh(mesh: Mesh): void;
  50423. /**
  50424. * Dispose the highlight layer and free resources.
  50425. */
  50426. dispose(): void;
  50427. /**
  50428. * Gets the class name of the effect layer
  50429. * @returns the string with the class name of the effect layer
  50430. */
  50431. getClassName(): string;
  50432. /**
  50433. * Serializes this Highlight layer
  50434. * @returns a serialized Highlight layer object
  50435. */
  50436. serialize(): any;
  50437. /**
  50438. * Creates a Highlight layer from parsed Highlight layer data
  50439. * @param parsedHightlightLayer defines the Highlight layer data
  50440. * @param scene defines the current scene
  50441. * @param rootUrl defines the root URL containing the Highlight layer information
  50442. * @returns a parsed Highlight layer
  50443. */
  50444. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. interface AbstractScene {
  50449. /**
  50450. * The list of layers (background and foreground) of the scene
  50451. */
  50452. layers: Array<Layer>;
  50453. }
  50454. /**
  50455. * Defines the layer scene component responsible to manage any layers
  50456. * in a given scene.
  50457. */
  50458. export class LayerSceneComponent implements ISceneComponent {
  50459. /**
  50460. * The component name helpfull to identify the component in the list of scene components.
  50461. */
  50462. readonly name: string;
  50463. /**
  50464. * The scene the component belongs to.
  50465. */
  50466. scene: Scene;
  50467. private _engine;
  50468. /**
  50469. * Creates a new instance of the component for the given scene
  50470. * @param scene Defines the scene to register the component in
  50471. */
  50472. constructor(scene: Scene);
  50473. /**
  50474. * Registers the component in a given scene
  50475. */
  50476. register(): void;
  50477. /**
  50478. * Rebuilds the elements related to this component in case of
  50479. * context lost for instance.
  50480. */
  50481. rebuild(): void;
  50482. /**
  50483. * Disposes the component and the associated ressources.
  50484. */
  50485. dispose(): void;
  50486. private _draw;
  50487. private _drawCameraPredicate;
  50488. private _drawCameraBackground;
  50489. private _drawCameraForeground;
  50490. private _drawRenderTargetPredicate;
  50491. private _drawRenderTargetBackground;
  50492. private _drawRenderTargetForeground;
  50493. /**
  50494. * Adds all the elements from the container to the scene
  50495. * @param container the container holding the elements
  50496. */
  50497. addFromContainer(container: AbstractScene): void;
  50498. /**
  50499. * Removes all the elements in the container from the scene
  50500. * @param container contains the elements to remove
  50501. * @param dispose if the removed element should be disposed (default: false)
  50502. */
  50503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50504. }
  50505. }
  50506. declare module BABYLON {
  50507. /** @hidden */
  50508. export var layerPixelShader: {
  50509. name: string;
  50510. shader: string;
  50511. };
  50512. }
  50513. declare module BABYLON {
  50514. /** @hidden */
  50515. export var layerVertexShader: {
  50516. name: string;
  50517. shader: string;
  50518. };
  50519. }
  50520. declare module BABYLON {
  50521. /**
  50522. * This represents a full screen 2d layer.
  50523. * This can be useful to display a picture in the background of your scene for instance.
  50524. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50525. */
  50526. export class Layer {
  50527. /**
  50528. * Define the name of the layer.
  50529. */
  50530. name: string;
  50531. /**
  50532. * Define the texture the layer should display.
  50533. */
  50534. texture: Nullable<Texture>;
  50535. /**
  50536. * Is the layer in background or foreground.
  50537. */
  50538. isBackground: boolean;
  50539. /**
  50540. * Define the color of the layer (instead of texture).
  50541. */
  50542. color: Color4;
  50543. /**
  50544. * Define the scale of the layer in order to zoom in out of the texture.
  50545. */
  50546. scale: Vector2;
  50547. /**
  50548. * Define an offset for the layer in order to shift the texture.
  50549. */
  50550. offset: Vector2;
  50551. /**
  50552. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50553. */
  50554. alphaBlendingMode: number;
  50555. /**
  50556. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50557. * Alpha test will not mix with the background color in case of transparency.
  50558. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50559. */
  50560. alphaTest: boolean;
  50561. /**
  50562. * Define a mask to restrict the layer to only some of the scene cameras.
  50563. */
  50564. layerMask: number;
  50565. /**
  50566. * Define the list of render target the layer is visible into.
  50567. */
  50568. renderTargetTextures: RenderTargetTexture[];
  50569. /**
  50570. * Define if the layer is only used in renderTarget or if it also
  50571. * renders in the main frame buffer of the canvas.
  50572. */
  50573. renderOnlyInRenderTargetTextures: boolean;
  50574. private _scene;
  50575. private _vertexBuffers;
  50576. private _indexBuffer;
  50577. private _effect;
  50578. private _alphaTestEffect;
  50579. /**
  50580. * An event triggered when the layer is disposed.
  50581. */
  50582. onDisposeObservable: Observable<Layer>;
  50583. private _onDisposeObserver;
  50584. /**
  50585. * Back compatibility with callback before the onDisposeObservable existed.
  50586. * The set callback will be triggered when the layer has been disposed.
  50587. */
  50588. onDispose: () => void;
  50589. /**
  50590. * An event triggered before rendering the scene
  50591. */
  50592. onBeforeRenderObservable: Observable<Layer>;
  50593. private _onBeforeRenderObserver;
  50594. /**
  50595. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50596. * The set callback will be triggered just before rendering the layer.
  50597. */
  50598. onBeforeRender: () => void;
  50599. /**
  50600. * An event triggered after rendering the scene
  50601. */
  50602. onAfterRenderObservable: Observable<Layer>;
  50603. private _onAfterRenderObserver;
  50604. /**
  50605. * Back compatibility with callback before the onAfterRenderObservable existed.
  50606. * The set callback will be triggered just after rendering the layer.
  50607. */
  50608. onAfterRender: () => void;
  50609. /**
  50610. * Instantiates a new layer.
  50611. * This represents a full screen 2d layer.
  50612. * This can be useful to display a picture in the background of your scene for instance.
  50613. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50614. * @param name Define the name of the layer in the scene
  50615. * @param imgUrl Define the url of the texture to display in the layer
  50616. * @param scene Define the scene the layer belongs to
  50617. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50618. * @param color Defines a color for the layer
  50619. */
  50620. constructor(
  50621. /**
  50622. * Define the name of the layer.
  50623. */
  50624. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50625. private _createIndexBuffer;
  50626. /** @hidden */
  50627. _rebuild(): void;
  50628. /**
  50629. * Renders the layer in the scene.
  50630. */
  50631. render(): void;
  50632. /**
  50633. * Disposes and releases the associated ressources.
  50634. */
  50635. dispose(): void;
  50636. }
  50637. }
  50638. declare module BABYLON {
  50639. /** @hidden */
  50640. export var lensFlarePixelShader: {
  50641. name: string;
  50642. shader: string;
  50643. };
  50644. }
  50645. declare module BABYLON {
  50646. /** @hidden */
  50647. export var lensFlareVertexShader: {
  50648. name: string;
  50649. shader: string;
  50650. };
  50651. }
  50652. declare module BABYLON {
  50653. /**
  50654. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50655. * It is usually composed of several `lensFlare`.
  50656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50657. */
  50658. export class LensFlareSystem {
  50659. /**
  50660. * Define the name of the lens flare system
  50661. */
  50662. name: string;
  50663. /**
  50664. * List of lens flares used in this system.
  50665. */
  50666. lensFlares: LensFlare[];
  50667. /**
  50668. * Define a limit from the border the lens flare can be visible.
  50669. */
  50670. borderLimit: number;
  50671. /**
  50672. * Define a viewport border we do not want to see the lens flare in.
  50673. */
  50674. viewportBorder: number;
  50675. /**
  50676. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50677. */
  50678. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50679. /**
  50680. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50681. */
  50682. layerMask: number;
  50683. /**
  50684. * Define the id of the lens flare system in the scene.
  50685. * (equal to name by default)
  50686. */
  50687. id: string;
  50688. private _scene;
  50689. private _emitter;
  50690. private _vertexBuffers;
  50691. private _indexBuffer;
  50692. private _effect;
  50693. private _positionX;
  50694. private _positionY;
  50695. private _isEnabled;
  50696. /** @hidden */
  50697. static _SceneComponentInitialization: (scene: Scene) => void;
  50698. /**
  50699. * Instantiates a lens flare system.
  50700. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50701. * It is usually composed of several `lensFlare`.
  50702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50703. * @param name Define the name of the lens flare system in the scene
  50704. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50705. * @param scene Define the scene the lens flare system belongs to
  50706. */
  50707. constructor(
  50708. /**
  50709. * Define the name of the lens flare system
  50710. */
  50711. name: string, emitter: any, scene: Scene);
  50712. /**
  50713. * Define if the lens flare system is enabled.
  50714. */
  50715. isEnabled: boolean;
  50716. /**
  50717. * Get the scene the effects belongs to.
  50718. * @returns the scene holding the lens flare system
  50719. */
  50720. getScene(): Scene;
  50721. /**
  50722. * Get the emitter of the lens flare system.
  50723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50724. * @returns the emitter of the lens flare system
  50725. */
  50726. getEmitter(): any;
  50727. /**
  50728. * Set the emitter of the lens flare system.
  50729. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50730. * @param newEmitter Define the new emitter of the system
  50731. */
  50732. setEmitter(newEmitter: any): void;
  50733. /**
  50734. * Get the lens flare system emitter position.
  50735. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50736. * @returns the position
  50737. */
  50738. getEmitterPosition(): Vector3;
  50739. /**
  50740. * @hidden
  50741. */
  50742. computeEffectivePosition(globalViewport: Viewport): boolean;
  50743. /** @hidden */
  50744. _isVisible(): boolean;
  50745. /**
  50746. * @hidden
  50747. */
  50748. render(): boolean;
  50749. /**
  50750. * Dispose and release the lens flare with its associated resources.
  50751. */
  50752. dispose(): void;
  50753. /**
  50754. * Parse a lens flare system from a JSON repressentation
  50755. * @param parsedLensFlareSystem Define the JSON to parse
  50756. * @param scene Define the scene the parsed system should be instantiated in
  50757. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50758. * @returns the parsed system
  50759. */
  50760. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50761. /**
  50762. * Serialize the current Lens Flare System into a JSON representation.
  50763. * @returns the serialized JSON
  50764. */
  50765. serialize(): any;
  50766. }
  50767. }
  50768. declare module BABYLON {
  50769. /**
  50770. * This represents one of the lens effect in a `lensFlareSystem`.
  50771. * It controls one of the indiviual texture used in the effect.
  50772. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50773. */
  50774. export class LensFlare {
  50775. /**
  50776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50777. */
  50778. size: number;
  50779. /**
  50780. * 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.
  50781. */
  50782. position: number;
  50783. /**
  50784. * Define the lens color.
  50785. */
  50786. color: Color3;
  50787. /**
  50788. * Define the lens texture.
  50789. */
  50790. texture: Nullable<Texture>;
  50791. /**
  50792. * Define the alpha mode to render this particular lens.
  50793. */
  50794. alphaMode: number;
  50795. private _system;
  50796. /**
  50797. * Creates a new Lens Flare.
  50798. * This represents one of the lens effect in a `lensFlareSystem`.
  50799. * It controls one of the indiviual texture used in the effect.
  50800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50801. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50802. * @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.
  50803. * @param color Define the lens color
  50804. * @param imgUrl Define the lens texture url
  50805. * @param system Define the `lensFlareSystem` this flare is part of
  50806. * @returns The newly created Lens Flare
  50807. */
  50808. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50809. /**
  50810. * Instantiates a new Lens Flare.
  50811. * This represents one of the lens effect in a `lensFlareSystem`.
  50812. * It controls one of the indiviual texture used in the effect.
  50813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50814. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50815. * @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.
  50816. * @param color Define the lens color
  50817. * @param imgUrl Define the lens texture url
  50818. * @param system Define the `lensFlareSystem` this flare is part of
  50819. */
  50820. constructor(
  50821. /**
  50822. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50823. */
  50824. size: number,
  50825. /**
  50826. * 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.
  50827. */
  50828. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50829. /**
  50830. * Dispose and release the lens flare with its associated resources.
  50831. */
  50832. dispose(): void;
  50833. }
  50834. }
  50835. declare module BABYLON {
  50836. interface AbstractScene {
  50837. /**
  50838. * The list of lens flare system added to the scene
  50839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50840. */
  50841. lensFlareSystems: Array<LensFlareSystem>;
  50842. /**
  50843. * Removes the given lens flare system from this scene.
  50844. * @param toRemove The lens flare system to remove
  50845. * @returns The index of the removed lens flare system
  50846. */
  50847. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50848. /**
  50849. * Adds the given lens flare system to this scene
  50850. * @param newLensFlareSystem The lens flare system to add
  50851. */
  50852. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50853. /**
  50854. * Gets a lens flare system using its name
  50855. * @param name defines the name to look for
  50856. * @returns the lens flare system or null if not found
  50857. */
  50858. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50859. /**
  50860. * Gets a lens flare system using its id
  50861. * @param id defines the id to look for
  50862. * @returns the lens flare system or null if not found
  50863. */
  50864. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50865. }
  50866. /**
  50867. * Defines the lens flare scene component responsible to manage any lens flares
  50868. * in a given scene.
  50869. */
  50870. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50871. /**
  50872. * The component name helpfull to identify the component in the list of scene components.
  50873. */
  50874. readonly name: string;
  50875. /**
  50876. * The scene the component belongs to.
  50877. */
  50878. scene: Scene;
  50879. /**
  50880. * Creates a new instance of the component for the given scene
  50881. * @param scene Defines the scene to register the component in
  50882. */
  50883. constructor(scene: Scene);
  50884. /**
  50885. * Registers the component in a given scene
  50886. */
  50887. register(): void;
  50888. /**
  50889. * Rebuilds the elements related to this component in case of
  50890. * context lost for instance.
  50891. */
  50892. rebuild(): void;
  50893. /**
  50894. * Adds all the elements from the container to the scene
  50895. * @param container the container holding the elements
  50896. */
  50897. addFromContainer(container: AbstractScene): void;
  50898. /**
  50899. * Removes all the elements in the container from the scene
  50900. * @param container contains the elements to remove
  50901. * @param dispose if the removed element should be disposed (default: false)
  50902. */
  50903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50904. /**
  50905. * Serializes the component data to the specified json object
  50906. * @param serializationObject The object to serialize to
  50907. */
  50908. serialize(serializationObject: any): void;
  50909. /**
  50910. * Disposes the component and the associated ressources.
  50911. */
  50912. dispose(): void;
  50913. private _draw;
  50914. }
  50915. }
  50916. declare module BABYLON {
  50917. /**
  50918. * Defines the shadow generator component responsible to manage any shadow generators
  50919. * in a given scene.
  50920. */
  50921. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50922. /**
  50923. * The component name helpfull to identify the component in the list of scene components.
  50924. */
  50925. readonly name: string;
  50926. /**
  50927. * The scene the component belongs to.
  50928. */
  50929. scene: Scene;
  50930. /**
  50931. * Creates a new instance of the component for the given scene
  50932. * @param scene Defines the scene to register the component in
  50933. */
  50934. constructor(scene: Scene);
  50935. /**
  50936. * Registers the component in a given scene
  50937. */
  50938. register(): void;
  50939. /**
  50940. * Rebuilds the elements related to this component in case of
  50941. * context lost for instance.
  50942. */
  50943. rebuild(): void;
  50944. /**
  50945. * Serializes the component data to the specified json object
  50946. * @param serializationObject The object to serialize to
  50947. */
  50948. serialize(serializationObject: any): void;
  50949. /**
  50950. * Adds all the elements from the container to the scene
  50951. * @param container the container holding the elements
  50952. */
  50953. addFromContainer(container: AbstractScene): void;
  50954. /**
  50955. * Removes all the elements in the container from the scene
  50956. * @param container contains the elements to remove
  50957. * @param dispose if the removed element should be disposed (default: false)
  50958. */
  50959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50960. /**
  50961. * Rebuilds the elements related to this component in case of
  50962. * context lost for instance.
  50963. */
  50964. dispose(): void;
  50965. private _gatherRenderTargets;
  50966. }
  50967. }
  50968. declare module BABYLON {
  50969. /**
  50970. * A point light is a light defined by an unique point in world space.
  50971. * The light is emitted in every direction from this point.
  50972. * A good example of a point light is a standard light bulb.
  50973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50974. */
  50975. export class PointLight extends ShadowLight {
  50976. private _shadowAngle;
  50977. /**
  50978. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50979. * This specifies what angle the shadow will use to be created.
  50980. *
  50981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50982. */
  50983. /**
  50984. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50985. * This specifies what angle the shadow will use to be created.
  50986. *
  50987. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50988. */
  50989. shadowAngle: number;
  50990. /**
  50991. * Gets the direction if it has been set.
  50992. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50993. */
  50994. /**
  50995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50996. */
  50997. direction: Vector3;
  50998. /**
  50999. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51000. * A PointLight emits the light in every direction.
  51001. * It can cast shadows.
  51002. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51003. * ```javascript
  51004. * var pointLight = new PointLight("pl", camera.position, scene);
  51005. * ```
  51006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51007. * @param name The light friendly name
  51008. * @param position The position of the point light in the scene
  51009. * @param scene The scene the lights belongs to
  51010. */
  51011. constructor(name: string, position: Vector3, scene: Scene);
  51012. /**
  51013. * Returns the string "PointLight"
  51014. * @returns the class name
  51015. */
  51016. getClassName(): string;
  51017. /**
  51018. * Returns the integer 0.
  51019. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51020. */
  51021. getTypeID(): number;
  51022. /**
  51023. * Specifies wether or not the shadowmap should be a cube texture.
  51024. * @returns true if the shadowmap needs to be a cube texture.
  51025. */
  51026. needCube(): boolean;
  51027. /**
  51028. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51029. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51030. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51031. */
  51032. getShadowDirection(faceIndex?: number): Vector3;
  51033. /**
  51034. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51035. * - fov = PI / 2
  51036. * - aspect ratio : 1.0
  51037. * - z-near and far equal to the active camera minZ and maxZ.
  51038. * Returns the PointLight.
  51039. */
  51040. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51041. protected _buildUniformLayout(): void;
  51042. /**
  51043. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51044. * @param effect The effect to update
  51045. * @param lightIndex The index of the light in the effect to update
  51046. * @returns The point light
  51047. */
  51048. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51049. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51050. /**
  51051. * Prepares the list of defines specific to the light type.
  51052. * @param defines the list of defines
  51053. * @param lightIndex defines the index of the light for the effect
  51054. */
  51055. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Header information of HDR texture files.
  51061. */
  51062. export interface HDRInfo {
  51063. /**
  51064. * The height of the texture in pixels.
  51065. */
  51066. height: number;
  51067. /**
  51068. * The width of the texture in pixels.
  51069. */
  51070. width: number;
  51071. /**
  51072. * The index of the beginning of the data in the binary file.
  51073. */
  51074. dataPosition: number;
  51075. }
  51076. /**
  51077. * This groups tools to convert HDR texture to native colors array.
  51078. */
  51079. export class HDRTools {
  51080. private static Ldexp;
  51081. private static Rgbe2float;
  51082. private static readStringLine;
  51083. /**
  51084. * Reads header information from an RGBE texture stored in a native array.
  51085. * More information on this format are available here:
  51086. * https://en.wikipedia.org/wiki/RGBE_image_format
  51087. *
  51088. * @param uint8array The binary file stored in native array.
  51089. * @return The header information.
  51090. */
  51091. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51092. /**
  51093. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51094. * This RGBE texture needs to store the information as a panorama.
  51095. *
  51096. * More information on this format are available here:
  51097. * https://en.wikipedia.org/wiki/RGBE_image_format
  51098. *
  51099. * @param buffer The binary file stored in an array buffer.
  51100. * @param size The expected size of the extracted cubemap.
  51101. * @return The Cube Map information.
  51102. */
  51103. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51104. /**
  51105. * Returns the pixels data extracted from an RGBE texture.
  51106. * This pixels will be stored left to right up to down in the R G B order in one array.
  51107. *
  51108. * More information on this format are available here:
  51109. * https://en.wikipedia.org/wiki/RGBE_image_format
  51110. *
  51111. * @param uint8array The binary file stored in an array buffer.
  51112. * @param hdrInfo The header information of the file.
  51113. * @return The pixels data in RGB right to left up to down order.
  51114. */
  51115. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51116. private static RGBE_ReadPixels_RLE;
  51117. }
  51118. }
  51119. declare module BABYLON {
  51120. /**
  51121. * This represents a texture coming from an HDR input.
  51122. *
  51123. * The only supported format is currently panorama picture stored in RGBE format.
  51124. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51125. */
  51126. export class HDRCubeTexture extends BaseTexture {
  51127. private static _facesMapping;
  51128. private _generateHarmonics;
  51129. private _noMipmap;
  51130. private _textureMatrix;
  51131. private _size;
  51132. private _onLoad;
  51133. private _onError;
  51134. /**
  51135. * The texture URL.
  51136. */
  51137. url: string;
  51138. /**
  51139. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51140. */
  51141. coordinatesMode: number;
  51142. protected _isBlocking: boolean;
  51143. /**
  51144. * Sets wether or not the texture is blocking during loading.
  51145. */
  51146. /**
  51147. * Gets wether or not the texture is blocking during loading.
  51148. */
  51149. isBlocking: boolean;
  51150. protected _rotationY: number;
  51151. /**
  51152. * Sets texture matrix rotation angle around Y axis in radians.
  51153. */
  51154. /**
  51155. * Gets texture matrix rotation angle around Y axis radians.
  51156. */
  51157. rotationY: number;
  51158. /**
  51159. * Gets or sets the center of the bounding box associated with the cube texture
  51160. * It must define where the camera used to render the texture was set
  51161. */
  51162. boundingBoxPosition: Vector3;
  51163. private _boundingBoxSize;
  51164. /**
  51165. * Gets or sets the size of the bounding box associated with the cube texture
  51166. * When defined, the cubemap will switch to local mode
  51167. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51168. * @example https://www.babylonjs-playground.com/#RNASML
  51169. */
  51170. boundingBoxSize: Vector3;
  51171. /**
  51172. * Instantiates an HDRTexture from the following parameters.
  51173. *
  51174. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51175. * @param scene The scene the texture will be used in
  51176. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51177. * @param noMipmap Forces to not generate the mipmap if true
  51178. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51179. * @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)
  51180. * @param reserved Reserved flag for internal use.
  51181. */
  51182. 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>);
  51183. /**
  51184. * Get the current class name of the texture useful for serialization or dynamic coding.
  51185. * @returns "HDRCubeTexture"
  51186. */
  51187. getClassName(): string;
  51188. /**
  51189. * Occurs when the file is raw .hdr file.
  51190. */
  51191. private loadTexture;
  51192. clone(): HDRCubeTexture;
  51193. delayLoad(): void;
  51194. /**
  51195. * Get the texture reflection matrix used to rotate/transform the reflection.
  51196. * @returns the reflection matrix
  51197. */
  51198. getReflectionTextureMatrix(): Matrix;
  51199. /**
  51200. * Set the texture reflection matrix used to rotate/transform the reflection.
  51201. * @param value Define the reflection matrix to set
  51202. */
  51203. setReflectionTextureMatrix(value: Matrix): void;
  51204. /**
  51205. * Parses a JSON representation of an HDR Texture in order to create the texture
  51206. * @param parsedTexture Define the JSON representation
  51207. * @param scene Define the scene the texture should be created in
  51208. * @param rootUrl Define the root url in case we need to load relative dependencies
  51209. * @returns the newly created texture after parsing
  51210. */
  51211. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51212. serialize(): any;
  51213. }
  51214. }
  51215. declare module BABYLON {
  51216. /**
  51217. * Class used to control physics engine
  51218. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51219. */
  51220. export class PhysicsEngine implements IPhysicsEngine {
  51221. private _physicsPlugin;
  51222. /**
  51223. * Global value used to control the smallest number supported by the simulation
  51224. */
  51225. static Epsilon: number;
  51226. private _impostors;
  51227. private _joints;
  51228. /**
  51229. * Gets the gravity vector used by the simulation
  51230. */
  51231. gravity: Vector3;
  51232. /**
  51233. * Factory used to create the default physics plugin.
  51234. * @returns The default physics plugin
  51235. */
  51236. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51237. /**
  51238. * Creates a new Physics Engine
  51239. * @param gravity defines the gravity vector used by the simulation
  51240. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51241. */
  51242. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51243. /**
  51244. * Sets the gravity vector used by the simulation
  51245. * @param gravity defines the gravity vector to use
  51246. */
  51247. setGravity(gravity: Vector3): void;
  51248. /**
  51249. * Set the time step of the physics engine.
  51250. * Default is 1/60.
  51251. * To slow it down, enter 1/600 for example.
  51252. * To speed it up, 1/30
  51253. * @param newTimeStep defines the new timestep to apply to this world.
  51254. */
  51255. setTimeStep(newTimeStep?: number): void;
  51256. /**
  51257. * Get the time step of the physics engine.
  51258. * @returns the current time step
  51259. */
  51260. getTimeStep(): number;
  51261. /**
  51262. * Release all resources
  51263. */
  51264. dispose(): void;
  51265. /**
  51266. * Gets the name of the current physics plugin
  51267. * @returns the name of the plugin
  51268. */
  51269. getPhysicsPluginName(): string;
  51270. /**
  51271. * Adding a new impostor for the impostor tracking.
  51272. * This will be done by the impostor itself.
  51273. * @param impostor the impostor to add
  51274. */
  51275. addImpostor(impostor: PhysicsImpostor): void;
  51276. /**
  51277. * Remove an impostor from the engine.
  51278. * This impostor and its mesh will not longer be updated by the physics engine.
  51279. * @param impostor the impostor to remove
  51280. */
  51281. removeImpostor(impostor: PhysicsImpostor): void;
  51282. /**
  51283. * Add a joint to the physics engine
  51284. * @param mainImpostor defines the main impostor to which the joint is added.
  51285. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51286. * @param joint defines the joint that will connect both impostors.
  51287. */
  51288. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51289. /**
  51290. * Removes a joint from the simulation
  51291. * @param mainImpostor defines the impostor used with the joint
  51292. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51293. * @param joint defines the joint to remove
  51294. */
  51295. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51296. /**
  51297. * Called by the scene. No need to call it.
  51298. * @param delta defines the timespam between frames
  51299. */
  51300. _step(delta: number): void;
  51301. /**
  51302. * Gets the current plugin used to run the simulation
  51303. * @returns current plugin
  51304. */
  51305. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51306. /**
  51307. * Gets the list of physic impostors
  51308. * @returns an array of PhysicsImpostor
  51309. */
  51310. getImpostors(): Array<PhysicsImpostor>;
  51311. /**
  51312. * Gets the impostor for a physics enabled object
  51313. * @param object defines the object impersonated by the impostor
  51314. * @returns the PhysicsImpostor or null if not found
  51315. */
  51316. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51317. /**
  51318. * Gets the impostor for a physics body object
  51319. * @param body defines physics body used by the impostor
  51320. * @returns the PhysicsImpostor or null if not found
  51321. */
  51322. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51323. /**
  51324. * Does a raycast in the physics world
  51325. * @param from when should the ray start?
  51326. * @param to when should the ray end?
  51327. * @returns PhysicsRaycastResult
  51328. */
  51329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51330. }
  51331. }
  51332. declare module BABYLON {
  51333. /** @hidden */
  51334. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51335. private _useDeltaForWorldStep;
  51336. world: any;
  51337. name: string;
  51338. private _physicsMaterials;
  51339. private _fixedTimeStep;
  51340. private _cannonRaycastResult;
  51341. private _raycastResult;
  51342. private _physicsBodysToRemoveAfterStep;
  51343. BJSCANNON: any;
  51344. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51345. setGravity(gravity: Vector3): void;
  51346. setTimeStep(timeStep: number): void;
  51347. getTimeStep(): number;
  51348. executeStep(delta: number): void;
  51349. private _removeMarkedPhysicsBodiesFromWorld;
  51350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51351. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51352. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51353. private _processChildMeshes;
  51354. removePhysicsBody(impostor: PhysicsImpostor): void;
  51355. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51356. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51357. private _addMaterial;
  51358. private _checkWithEpsilon;
  51359. private _createShape;
  51360. private _createHeightmap;
  51361. private _minus90X;
  51362. private _plus90X;
  51363. private _tmpPosition;
  51364. private _tmpDeltaPosition;
  51365. private _tmpUnityRotation;
  51366. private _updatePhysicsBodyTransformation;
  51367. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51368. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51369. isSupported(): boolean;
  51370. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51371. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51372. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51373. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51374. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51375. getBodyMass(impostor: PhysicsImpostor): number;
  51376. getBodyFriction(impostor: PhysicsImpostor): number;
  51377. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51378. getBodyRestitution(impostor: PhysicsImpostor): number;
  51379. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51380. sleepBody(impostor: PhysicsImpostor): void;
  51381. wakeUpBody(impostor: PhysicsImpostor): void;
  51382. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51383. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51384. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51386. getRadius(impostor: PhysicsImpostor): number;
  51387. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51388. dispose(): void;
  51389. private _extendNamespace;
  51390. /**
  51391. * Does a raycast in the physics world
  51392. * @param from when should the ray start?
  51393. * @param to when should the ray end?
  51394. * @returns PhysicsRaycastResult
  51395. */
  51396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51397. }
  51398. }
  51399. declare module BABYLON {
  51400. /** @hidden */
  51401. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51402. world: any;
  51403. name: string;
  51404. BJSOIMO: any;
  51405. private _raycastResult;
  51406. constructor(iterations?: number, oimoInjection?: any);
  51407. setGravity(gravity: Vector3): void;
  51408. setTimeStep(timeStep: number): void;
  51409. getTimeStep(): number;
  51410. private _tmpImpostorsArray;
  51411. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51412. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51413. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51414. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51415. private _tmpPositionVector;
  51416. removePhysicsBody(impostor: PhysicsImpostor): void;
  51417. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51418. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51419. isSupported(): boolean;
  51420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51427. getBodyMass(impostor: PhysicsImpostor): number;
  51428. getBodyFriction(impostor: PhysicsImpostor): number;
  51429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51430. getBodyRestitution(impostor: PhysicsImpostor): number;
  51431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51432. sleepBody(impostor: PhysicsImpostor): void;
  51433. wakeUpBody(impostor: PhysicsImpostor): void;
  51434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51435. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51437. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51438. getRadius(impostor: PhysicsImpostor): number;
  51439. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51440. dispose(): void;
  51441. /**
  51442. * Does a raycast in the physics world
  51443. * @param from when should the ray start?
  51444. * @param to when should the ray end?
  51445. * @returns PhysicsRaycastResult
  51446. */
  51447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51448. }
  51449. }
  51450. declare module BABYLON {
  51451. /**
  51452. * Class containing static functions to help procedurally build meshes
  51453. */
  51454. export class RibbonBuilder {
  51455. /**
  51456. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51457. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51458. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51459. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51460. * * 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
  51461. * * 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
  51462. * * 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
  51463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51464. * * 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
  51465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51466. * * 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
  51467. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51468. * * 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
  51469. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51471. * @param name defines the name of the mesh
  51472. * @param options defines the options used to create the mesh
  51473. * @param scene defines the hosting scene
  51474. * @returns the ribbon mesh
  51475. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51476. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51477. */
  51478. static CreateRibbon(name: string, options: {
  51479. pathArray: Vector3[][];
  51480. closeArray?: boolean;
  51481. closePath?: boolean;
  51482. offset?: number;
  51483. updatable?: boolean;
  51484. sideOrientation?: number;
  51485. frontUVs?: Vector4;
  51486. backUVs?: Vector4;
  51487. instance?: Mesh;
  51488. invertUV?: boolean;
  51489. uvs?: Vector2[];
  51490. colors?: Color4[];
  51491. }, scene?: Nullable<Scene>): Mesh;
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /**
  51496. * Class containing static functions to help procedurally build meshes
  51497. */
  51498. export class ShapeBuilder {
  51499. /**
  51500. * 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.
  51501. * * 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.
  51502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51503. * * 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.
  51504. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51505. * * 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
  51506. * * 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
  51507. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51509. * * 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
  51510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51512. * @param name defines the name of the mesh
  51513. * @param options defines the options used to create the mesh
  51514. * @param scene defines the hosting scene
  51515. * @returns the extruded shape mesh
  51516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51518. */
  51519. static ExtrudeShape(name: string, options: {
  51520. shape: Vector3[];
  51521. path: Vector3[];
  51522. scale?: number;
  51523. rotation?: number;
  51524. cap?: number;
  51525. updatable?: boolean;
  51526. sideOrientation?: number;
  51527. frontUVs?: Vector4;
  51528. backUVs?: Vector4;
  51529. instance?: Mesh;
  51530. invertUV?: boolean;
  51531. }, scene?: Nullable<Scene>): Mesh;
  51532. /**
  51533. * Creates an custom extruded shape mesh.
  51534. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51535. * * 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.
  51536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51537. * * 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
  51538. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51539. * * 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
  51540. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51541. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51542. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51543. * * 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
  51544. * * 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
  51545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51547. * * 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
  51548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51550. * @param name defines the name of the mesh
  51551. * @param options defines the options used to create the mesh
  51552. * @param scene defines the hosting scene
  51553. * @returns the custom extruded shape mesh
  51554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51557. */
  51558. static ExtrudeShapeCustom(name: string, options: {
  51559. shape: Vector3[];
  51560. path: Vector3[];
  51561. scaleFunction?: any;
  51562. rotationFunction?: any;
  51563. ribbonCloseArray?: boolean;
  51564. ribbonClosePath?: boolean;
  51565. cap?: number;
  51566. updatable?: boolean;
  51567. sideOrientation?: number;
  51568. frontUVs?: Vector4;
  51569. backUVs?: Vector4;
  51570. instance?: Mesh;
  51571. invertUV?: boolean;
  51572. }, scene?: Nullable<Scene>): Mesh;
  51573. private static _ExtrudeShapeGeneric;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /**
  51578. * AmmoJS Physics plugin
  51579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51580. * @see https://github.com/kripken/ammo.js/
  51581. */
  51582. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51583. private _useDeltaForWorldStep;
  51584. /**
  51585. * Reference to the Ammo library
  51586. */
  51587. bjsAMMO: any;
  51588. /**
  51589. * Created ammoJS world which physics bodies are added to
  51590. */
  51591. world: any;
  51592. /**
  51593. * Name of the plugin
  51594. */
  51595. name: string;
  51596. private _timeStep;
  51597. private _fixedTimeStep;
  51598. private _maxSteps;
  51599. private _tmpQuaternion;
  51600. private _tmpAmmoTransform;
  51601. private _tmpAmmoQuaternion;
  51602. private _tmpAmmoConcreteContactResultCallback;
  51603. private _collisionConfiguration;
  51604. private _dispatcher;
  51605. private _overlappingPairCache;
  51606. private _solver;
  51607. private _softBodySolver;
  51608. private _tmpAmmoVectorA;
  51609. private _tmpAmmoVectorB;
  51610. private _tmpAmmoVectorC;
  51611. private _tmpAmmoVectorD;
  51612. private _tmpContactCallbackResult;
  51613. private _tmpAmmoVectorRCA;
  51614. private _tmpAmmoVectorRCB;
  51615. private _raycastResult;
  51616. private static readonly DISABLE_COLLISION_FLAG;
  51617. private static readonly KINEMATIC_FLAG;
  51618. private static readonly DISABLE_DEACTIVATION_FLAG;
  51619. /**
  51620. * Initializes the ammoJS plugin
  51621. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51622. * @param ammoInjection can be used to inject your own ammo reference
  51623. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51624. */
  51625. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51626. /**
  51627. * Sets the gravity of the physics world (m/(s^2))
  51628. * @param gravity Gravity to set
  51629. */
  51630. setGravity(gravity: Vector3): void;
  51631. /**
  51632. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51633. * @param timeStep timestep to use in seconds
  51634. */
  51635. setTimeStep(timeStep: number): void;
  51636. /**
  51637. * 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)
  51638. * @param fixedTimeStep fixedTimeStep to use in seconds
  51639. */
  51640. setFixedTimeStep(fixedTimeStep: number): void;
  51641. /**
  51642. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51643. * @param maxSteps the maximum number of steps by the physics engine per frame
  51644. */
  51645. setMaxSteps(maxSteps: number): void;
  51646. /**
  51647. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51648. * @returns the current timestep in seconds
  51649. */
  51650. getTimeStep(): number;
  51651. private _isImpostorInContact;
  51652. private _isImpostorPairInContact;
  51653. private _stepSimulation;
  51654. /**
  51655. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51656. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51657. * After the step the babylon meshes are set to the position of the physics imposters
  51658. * @param delta amount of time to step forward
  51659. * @param impostors array of imposters to update before/after the step
  51660. */
  51661. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51662. /**
  51663. * Update babylon mesh to match physics world object
  51664. * @param impostor imposter to match
  51665. */
  51666. private _afterSoftStep;
  51667. /**
  51668. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51669. * @param impostor imposter to match
  51670. */
  51671. private _ropeStep;
  51672. /**
  51673. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51674. * @param impostor imposter to match
  51675. */
  51676. private _softbodyOrClothStep;
  51677. private _tmpVector;
  51678. private _tmpMatrix;
  51679. /**
  51680. * Applies an impulse on the imposter
  51681. * @param impostor imposter to apply impulse to
  51682. * @param force amount of force to be applied to the imposter
  51683. * @param contactPoint the location to apply the impulse on the imposter
  51684. */
  51685. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51686. /**
  51687. * Applies a force on the imposter
  51688. * @param impostor imposter to apply force
  51689. * @param force amount of force to be applied to the imposter
  51690. * @param contactPoint the location to apply the force on the imposter
  51691. */
  51692. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51693. /**
  51694. * Creates a physics body using the plugin
  51695. * @param impostor the imposter to create the physics body on
  51696. */
  51697. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51698. /**
  51699. * Removes the physics body from the imposter and disposes of the body's memory
  51700. * @param impostor imposter to remove the physics body from
  51701. */
  51702. removePhysicsBody(impostor: PhysicsImpostor): void;
  51703. /**
  51704. * Generates a joint
  51705. * @param impostorJoint the imposter joint to create the joint with
  51706. */
  51707. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51708. /**
  51709. * Removes a joint
  51710. * @param impostorJoint the imposter joint to remove the joint from
  51711. */
  51712. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51713. private _addMeshVerts;
  51714. /**
  51715. * Initialise the soft body vertices to match its object's (mesh) vertices
  51716. * Softbody vertices (nodes) are in world space and to match this
  51717. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51718. * @param impostor to create the softbody for
  51719. */
  51720. private _softVertexData;
  51721. /**
  51722. * Create an impostor's soft body
  51723. * @param impostor to create the softbody for
  51724. */
  51725. private _createSoftbody;
  51726. /**
  51727. * Create cloth for an impostor
  51728. * @param impostor to create the softbody for
  51729. */
  51730. private _createCloth;
  51731. /**
  51732. * Create rope for an impostor
  51733. * @param impostor to create the softbody for
  51734. */
  51735. private _createRope;
  51736. private _addHullVerts;
  51737. private _createShape;
  51738. /**
  51739. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51740. * @param impostor imposter containing the physics body and babylon object
  51741. */
  51742. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51743. /**
  51744. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51745. * @param impostor imposter containing the physics body and babylon object
  51746. * @param newPosition new position
  51747. * @param newRotation new rotation
  51748. */
  51749. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51750. /**
  51751. * If this plugin is supported
  51752. * @returns true if its supported
  51753. */
  51754. isSupported(): boolean;
  51755. /**
  51756. * Sets the linear velocity of the physics body
  51757. * @param impostor imposter to set the velocity on
  51758. * @param velocity velocity to set
  51759. */
  51760. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51761. /**
  51762. * Sets the angular velocity of the physics body
  51763. * @param impostor imposter to set the velocity on
  51764. * @param velocity velocity to set
  51765. */
  51766. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51767. /**
  51768. * gets the linear velocity
  51769. * @param impostor imposter to get linear velocity from
  51770. * @returns linear velocity
  51771. */
  51772. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51773. /**
  51774. * gets the angular velocity
  51775. * @param impostor imposter to get angular velocity from
  51776. * @returns angular velocity
  51777. */
  51778. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51779. /**
  51780. * Sets the mass of physics body
  51781. * @param impostor imposter to set the mass on
  51782. * @param mass mass to set
  51783. */
  51784. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51785. /**
  51786. * Gets the mass of the physics body
  51787. * @param impostor imposter to get the mass from
  51788. * @returns mass
  51789. */
  51790. getBodyMass(impostor: PhysicsImpostor): number;
  51791. /**
  51792. * Gets friction of the impostor
  51793. * @param impostor impostor to get friction from
  51794. * @returns friction value
  51795. */
  51796. getBodyFriction(impostor: PhysicsImpostor): number;
  51797. /**
  51798. * Sets friction of the impostor
  51799. * @param impostor impostor to set friction on
  51800. * @param friction friction value
  51801. */
  51802. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51803. /**
  51804. * Gets restitution of the impostor
  51805. * @param impostor impostor to get restitution from
  51806. * @returns restitution value
  51807. */
  51808. getBodyRestitution(impostor: PhysicsImpostor): number;
  51809. /**
  51810. * Sets resitution of the impostor
  51811. * @param impostor impostor to set resitution on
  51812. * @param restitution resitution value
  51813. */
  51814. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51815. /**
  51816. * Gets pressure inside the impostor
  51817. * @param impostor impostor to get pressure from
  51818. * @returns pressure value
  51819. */
  51820. getBodyPressure(impostor: PhysicsImpostor): number;
  51821. /**
  51822. * Sets pressure inside a soft body impostor
  51823. * Cloth and rope must remain 0 pressure
  51824. * @param impostor impostor to set pressure on
  51825. * @param pressure pressure value
  51826. */
  51827. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51828. /**
  51829. * Gets stiffness of the impostor
  51830. * @param impostor impostor to get stiffness from
  51831. * @returns pressure value
  51832. */
  51833. getBodyStiffness(impostor: PhysicsImpostor): number;
  51834. /**
  51835. * Sets stiffness of the impostor
  51836. * @param impostor impostor to set stiffness on
  51837. * @param stiffness stiffness value from 0 to 1
  51838. */
  51839. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51840. /**
  51841. * Gets velocityIterations of the impostor
  51842. * @param impostor impostor to get velocity iterations from
  51843. * @returns velocityIterations value
  51844. */
  51845. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51846. /**
  51847. * Sets velocityIterations of the impostor
  51848. * @param impostor impostor to set velocity iterations on
  51849. * @param velocityIterations velocityIterations value
  51850. */
  51851. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51852. /**
  51853. * Gets positionIterations of the impostor
  51854. * @param impostor impostor to get position iterations from
  51855. * @returns positionIterations value
  51856. */
  51857. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51858. /**
  51859. * Sets positionIterations of the impostor
  51860. * @param impostor impostor to set position on
  51861. * @param positionIterations positionIterations value
  51862. */
  51863. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51864. /**
  51865. * Append an anchor to a cloth object
  51866. * @param impostor is the cloth impostor to add anchor to
  51867. * @param otherImpostor is the rigid impostor to anchor to
  51868. * @param width ratio across width from 0 to 1
  51869. * @param height ratio up height from 0 to 1
  51870. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51871. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51872. */
  51873. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51874. /**
  51875. * Append an hook to a rope object
  51876. * @param impostor is the rope impostor to add hook to
  51877. * @param otherImpostor is the rigid impostor to hook to
  51878. * @param length ratio along the rope from 0 to 1
  51879. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51880. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51881. */
  51882. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51883. /**
  51884. * Sleeps the physics body and stops it from being active
  51885. * @param impostor impostor to sleep
  51886. */
  51887. sleepBody(impostor: PhysicsImpostor): void;
  51888. /**
  51889. * Activates the physics body
  51890. * @param impostor impostor to activate
  51891. */
  51892. wakeUpBody(impostor: PhysicsImpostor): void;
  51893. /**
  51894. * Updates the distance parameters of the joint
  51895. * @param joint joint to update
  51896. * @param maxDistance maximum distance of the joint
  51897. * @param minDistance minimum distance of the joint
  51898. */
  51899. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51900. /**
  51901. * Sets a motor on the joint
  51902. * @param joint joint to set motor on
  51903. * @param speed speed of the motor
  51904. * @param maxForce maximum force of the motor
  51905. * @param motorIndex index of the motor
  51906. */
  51907. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51908. /**
  51909. * Sets the motors limit
  51910. * @param joint joint to set limit on
  51911. * @param upperLimit upper limit
  51912. * @param lowerLimit lower limit
  51913. */
  51914. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51915. /**
  51916. * Syncs the position and rotation of a mesh with the impostor
  51917. * @param mesh mesh to sync
  51918. * @param impostor impostor to update the mesh with
  51919. */
  51920. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51921. /**
  51922. * Gets the radius of the impostor
  51923. * @param impostor impostor to get radius from
  51924. * @returns the radius
  51925. */
  51926. getRadius(impostor: PhysicsImpostor): number;
  51927. /**
  51928. * Gets the box size of the impostor
  51929. * @param impostor impostor to get box size from
  51930. * @param result the resulting box size
  51931. */
  51932. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51933. /**
  51934. * Disposes of the impostor
  51935. */
  51936. dispose(): void;
  51937. /**
  51938. * Does a raycast in the physics world
  51939. * @param from when should the ray start?
  51940. * @param to when should the ray end?
  51941. * @returns PhysicsRaycastResult
  51942. */
  51943. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51944. }
  51945. }
  51946. declare module BABYLON {
  51947. interface AbstractScene {
  51948. /**
  51949. * The list of reflection probes added to the scene
  51950. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51951. */
  51952. reflectionProbes: Array<ReflectionProbe>;
  51953. /**
  51954. * Removes the given reflection probe from this scene.
  51955. * @param toRemove The reflection probe to remove
  51956. * @returns The index of the removed reflection probe
  51957. */
  51958. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51959. /**
  51960. * Adds the given reflection probe to this scene.
  51961. * @param newReflectionProbe The reflection probe to add
  51962. */
  51963. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51964. }
  51965. /**
  51966. * Class used to generate realtime reflection / refraction cube textures
  51967. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51968. */
  51969. export class ReflectionProbe {
  51970. /** defines the name of the probe */
  51971. name: string;
  51972. private _scene;
  51973. private _renderTargetTexture;
  51974. private _projectionMatrix;
  51975. private _viewMatrix;
  51976. private _target;
  51977. private _add;
  51978. private _attachedMesh;
  51979. private _invertYAxis;
  51980. /** Gets or sets probe position (center of the cube map) */
  51981. position: Vector3;
  51982. /**
  51983. * Creates a new reflection probe
  51984. * @param name defines the name of the probe
  51985. * @param size defines the texture resolution (for each face)
  51986. * @param scene defines the hosting scene
  51987. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51988. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51989. */
  51990. constructor(
  51991. /** defines the name of the probe */
  51992. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51993. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51994. samples: number;
  51995. /** Gets or sets the refresh rate to use (on every frame by default) */
  51996. refreshRate: number;
  51997. /**
  51998. * Gets the hosting scene
  51999. * @returns a Scene
  52000. */
  52001. getScene(): Scene;
  52002. /** Gets the internal CubeTexture used to render to */
  52003. readonly cubeTexture: RenderTargetTexture;
  52004. /** Gets the list of meshes to render */
  52005. readonly renderList: Nullable<AbstractMesh[]>;
  52006. /**
  52007. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52008. * @param mesh defines the mesh to attach to
  52009. */
  52010. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52011. /**
  52012. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52013. * @param renderingGroupId The rendering group id corresponding to its index
  52014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52015. */
  52016. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52017. /**
  52018. * Clean all associated resources
  52019. */
  52020. dispose(): void;
  52021. /**
  52022. * Converts the reflection probe information to a readable string for debug purpose.
  52023. * @param fullDetails Supports for multiple levels of logging within scene loading
  52024. * @returns the human readable reflection probe info
  52025. */
  52026. toString(fullDetails?: boolean): string;
  52027. /**
  52028. * Get the class name of the relfection probe.
  52029. * @returns "ReflectionProbe"
  52030. */
  52031. getClassName(): string;
  52032. /**
  52033. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52034. * @returns The JSON representation of the texture
  52035. */
  52036. serialize(): any;
  52037. /**
  52038. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52039. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52040. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52041. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52042. * @returns The parsed reflection probe if successful
  52043. */
  52044. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /** @hidden */
  52049. export var _BabylonLoaderRegistered: boolean;
  52050. /**
  52051. * Helps setting up some configuration for the babylon file loader.
  52052. */
  52053. export class BabylonFileLoaderConfiguration {
  52054. /**
  52055. * The loader does not allow injecting custom physix engine into the plugins.
  52056. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52057. * So you could set this variable to your engine import to make it work.
  52058. */
  52059. static LoaderInjectedPhysicsEngine: any;
  52060. }
  52061. }
  52062. declare module BABYLON {
  52063. /**
  52064. * The Physically based simple base material of BJS.
  52065. *
  52066. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52067. * It is used as the base class for both the specGloss and metalRough conventions.
  52068. */
  52069. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52070. /**
  52071. * Number of Simultaneous lights allowed on the material.
  52072. */
  52073. maxSimultaneousLights: number;
  52074. /**
  52075. * If sets to true, disables all the lights affecting the material.
  52076. */
  52077. disableLighting: boolean;
  52078. /**
  52079. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52080. */
  52081. environmentTexture: BaseTexture;
  52082. /**
  52083. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52084. */
  52085. invertNormalMapX: boolean;
  52086. /**
  52087. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52088. */
  52089. invertNormalMapY: boolean;
  52090. /**
  52091. * Normal map used in the model.
  52092. */
  52093. normalTexture: BaseTexture;
  52094. /**
  52095. * Emissivie color used to self-illuminate the model.
  52096. */
  52097. emissiveColor: Color3;
  52098. /**
  52099. * Emissivie texture used to self-illuminate the model.
  52100. */
  52101. emissiveTexture: BaseTexture;
  52102. /**
  52103. * Occlusion Channel Strenght.
  52104. */
  52105. occlusionStrength: number;
  52106. /**
  52107. * Occlusion Texture of the material (adding extra occlusion effects).
  52108. */
  52109. occlusionTexture: BaseTexture;
  52110. /**
  52111. * Defines the alpha limits in alpha test mode.
  52112. */
  52113. alphaCutOff: number;
  52114. /**
  52115. * Gets the current double sided mode.
  52116. */
  52117. /**
  52118. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52119. */
  52120. doubleSided: boolean;
  52121. /**
  52122. * Stores the pre-calculated light information of a mesh in a texture.
  52123. */
  52124. lightmapTexture: BaseTexture;
  52125. /**
  52126. * If true, the light map contains occlusion information instead of lighting info.
  52127. */
  52128. useLightmapAsShadowmap: boolean;
  52129. /**
  52130. * Instantiates a new PBRMaterial instance.
  52131. *
  52132. * @param name The material name
  52133. * @param scene The scene the material will be use in.
  52134. */
  52135. constructor(name: string, scene: Scene);
  52136. getClassName(): string;
  52137. }
  52138. }
  52139. declare module BABYLON {
  52140. /**
  52141. * The PBR material of BJS following the metal roughness convention.
  52142. *
  52143. * This fits to the PBR convention in the GLTF definition:
  52144. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52145. */
  52146. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52147. /**
  52148. * The base color has two different interpretations depending on the value of metalness.
  52149. * When the material is a metal, the base color is the specific measured reflectance value
  52150. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52151. * of the material.
  52152. */
  52153. baseColor: Color3;
  52154. /**
  52155. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52156. * well as opacity information in the alpha channel.
  52157. */
  52158. baseTexture: BaseTexture;
  52159. /**
  52160. * Specifies the metallic scalar value of the material.
  52161. * Can also be used to scale the metalness values of the metallic texture.
  52162. */
  52163. metallic: number;
  52164. /**
  52165. * Specifies the roughness scalar value of the material.
  52166. * Can also be used to scale the roughness values of the metallic texture.
  52167. */
  52168. roughness: number;
  52169. /**
  52170. * Texture containing both the metallic value in the B channel and the
  52171. * roughness value in the G channel to keep better precision.
  52172. */
  52173. metallicRoughnessTexture: BaseTexture;
  52174. /**
  52175. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52176. *
  52177. * @param name The material name
  52178. * @param scene The scene the material will be use in.
  52179. */
  52180. constructor(name: string, scene: Scene);
  52181. /**
  52182. * Return the currrent class name of the material.
  52183. */
  52184. getClassName(): string;
  52185. /**
  52186. * Makes a duplicate of the current material.
  52187. * @param name - name to use for the new material.
  52188. */
  52189. clone(name: string): PBRMetallicRoughnessMaterial;
  52190. /**
  52191. * Serialize the material to a parsable JSON object.
  52192. */
  52193. serialize(): any;
  52194. /**
  52195. * Parses a JSON object correponding to the serialize function.
  52196. */
  52197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52198. }
  52199. }
  52200. declare module BABYLON {
  52201. /**
  52202. * The PBR material of BJS following the specular glossiness convention.
  52203. *
  52204. * This fits to the PBR convention in the GLTF definition:
  52205. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52206. */
  52207. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52208. /**
  52209. * Specifies the diffuse color of the material.
  52210. */
  52211. diffuseColor: Color3;
  52212. /**
  52213. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52214. * channel.
  52215. */
  52216. diffuseTexture: BaseTexture;
  52217. /**
  52218. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52219. */
  52220. specularColor: Color3;
  52221. /**
  52222. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52223. */
  52224. glossiness: number;
  52225. /**
  52226. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52227. */
  52228. specularGlossinessTexture: BaseTexture;
  52229. /**
  52230. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52231. *
  52232. * @param name The material name
  52233. * @param scene The scene the material will be use in.
  52234. */
  52235. constructor(name: string, scene: Scene);
  52236. /**
  52237. * Return the currrent class name of the material.
  52238. */
  52239. getClassName(): string;
  52240. /**
  52241. * Makes a duplicate of the current material.
  52242. * @param name - name to use for the new material.
  52243. */
  52244. clone(name: string): PBRSpecularGlossinessMaterial;
  52245. /**
  52246. * Serialize the material to a parsable JSON object.
  52247. */
  52248. serialize(): any;
  52249. /**
  52250. * Parses a JSON object correponding to the serialize function.
  52251. */
  52252. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52253. }
  52254. }
  52255. declare module BABYLON {
  52256. /**
  52257. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52258. * It can help converting any input color in a desired output one. This can then be used to create effects
  52259. * from sepia, black and white to sixties or futuristic rendering...
  52260. *
  52261. * The only supported format is currently 3dl.
  52262. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52263. */
  52264. export class ColorGradingTexture extends BaseTexture {
  52265. /**
  52266. * The current texture matrix. (will always be identity in color grading texture)
  52267. */
  52268. private _textureMatrix;
  52269. /**
  52270. * The texture URL.
  52271. */
  52272. url: string;
  52273. /**
  52274. * Empty line regex stored for GC.
  52275. */
  52276. private static _noneEmptyLineRegex;
  52277. private _engine;
  52278. /**
  52279. * Instantiates a ColorGradingTexture from the following parameters.
  52280. *
  52281. * @param url The location of the color gradind data (currently only supporting 3dl)
  52282. * @param scene The scene the texture will be used in
  52283. */
  52284. constructor(url: string, scene: Scene);
  52285. /**
  52286. * Returns the texture matrix used in most of the material.
  52287. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52288. */
  52289. getTextureMatrix(): Matrix;
  52290. /**
  52291. * Occurs when the file being loaded is a .3dl LUT file.
  52292. */
  52293. private load3dlTexture;
  52294. /**
  52295. * Starts the loading process of the texture.
  52296. */
  52297. private loadTexture;
  52298. /**
  52299. * Clones the color gradind texture.
  52300. */
  52301. clone(): ColorGradingTexture;
  52302. /**
  52303. * Called during delayed load for textures.
  52304. */
  52305. delayLoad(): void;
  52306. /**
  52307. * Parses a color grading texture serialized by Babylon.
  52308. * @param parsedTexture The texture information being parsedTexture
  52309. * @param scene The scene to load the texture in
  52310. * @param rootUrl The root url of the data assets to load
  52311. * @return A color gradind texture
  52312. */
  52313. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52314. /**
  52315. * Serializes the LUT texture to json format.
  52316. */
  52317. serialize(): any;
  52318. }
  52319. }
  52320. declare module BABYLON {
  52321. /**
  52322. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52323. */
  52324. export class EquiRectangularCubeTexture extends BaseTexture {
  52325. /** The six faces of the cube. */
  52326. private static _FacesMapping;
  52327. private _noMipmap;
  52328. private _onLoad;
  52329. private _onError;
  52330. /** The size of the cubemap. */
  52331. private _size;
  52332. /** The buffer of the image. */
  52333. private _buffer;
  52334. /** The width of the input image. */
  52335. private _width;
  52336. /** The height of the input image. */
  52337. private _height;
  52338. /** The URL to the image. */
  52339. url: string;
  52340. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52341. coordinatesMode: number;
  52342. /**
  52343. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52344. * @param url The location of the image
  52345. * @param scene The scene the texture will be used in
  52346. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52347. * @param noMipmap Forces to not generate the mipmap if true
  52348. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52349. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52350. * @param onLoad — defines a callback called when texture is loaded
  52351. * @param onError — defines a callback called if there is an error
  52352. */
  52353. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52354. /**
  52355. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52356. */
  52357. private loadImage;
  52358. /**
  52359. * Convert the image buffer into a cubemap and create a CubeTexture.
  52360. */
  52361. private loadTexture;
  52362. /**
  52363. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52364. * @param buffer The ArrayBuffer that should be converted.
  52365. * @returns The buffer as Float32Array.
  52366. */
  52367. private getFloat32ArrayFromArrayBuffer;
  52368. /**
  52369. * Get the current class name of the texture useful for serialization or dynamic coding.
  52370. * @returns "EquiRectangularCubeTexture"
  52371. */
  52372. getClassName(): string;
  52373. /**
  52374. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52375. * @returns A clone of the current EquiRectangularCubeTexture.
  52376. */
  52377. clone(): EquiRectangularCubeTexture;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Based on jsTGALoader - Javascript loader for TGA file
  52383. * By Vincent Thibault
  52384. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52385. */
  52386. export class TGATools {
  52387. private static _TYPE_INDEXED;
  52388. private static _TYPE_RGB;
  52389. private static _TYPE_GREY;
  52390. private static _TYPE_RLE_INDEXED;
  52391. private static _TYPE_RLE_RGB;
  52392. private static _TYPE_RLE_GREY;
  52393. private static _ORIGIN_MASK;
  52394. private static _ORIGIN_SHIFT;
  52395. private static _ORIGIN_BL;
  52396. private static _ORIGIN_BR;
  52397. private static _ORIGIN_UL;
  52398. private static _ORIGIN_UR;
  52399. /**
  52400. * Gets the header of a TGA file
  52401. * @param data defines the TGA data
  52402. * @returns the header
  52403. */
  52404. static GetTGAHeader(data: Uint8Array): any;
  52405. /**
  52406. * Uploads TGA content to a Babylon Texture
  52407. * @hidden
  52408. */
  52409. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52410. /** @hidden */
  52411. 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;
  52412. /** @hidden */
  52413. 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;
  52414. /** @hidden */
  52415. 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;
  52416. /** @hidden */
  52417. 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;
  52418. /** @hidden */
  52419. 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;
  52420. /** @hidden */
  52421. 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;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * Implementation of the TGA Texture Loader.
  52427. * @hidden
  52428. */
  52429. export class _TGATextureLoader implements IInternalTextureLoader {
  52430. /**
  52431. * Defines wether the loader supports cascade loading the different faces.
  52432. */
  52433. readonly supportCascades: boolean;
  52434. /**
  52435. * This returns if the loader support the current file information.
  52436. * @param extension defines the file extension of the file being loaded
  52437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52438. * @param fallback defines the fallback internal texture if any
  52439. * @param isBase64 defines whether the texture is encoded as a base64
  52440. * @param isBuffer defines whether the texture data are stored as a buffer
  52441. * @returns true if the loader can load the specified file
  52442. */
  52443. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52444. /**
  52445. * Transform the url before loading if required.
  52446. * @param rootUrl the url of the texture
  52447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52448. * @returns the transformed texture
  52449. */
  52450. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52451. /**
  52452. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52453. * @param rootUrl the url of the texture
  52454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52455. * @returns the fallback texture
  52456. */
  52457. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52458. /**
  52459. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52460. * @param data contains the texture data
  52461. * @param texture defines the BabylonJS internal texture
  52462. * @param createPolynomials will be true if polynomials have been requested
  52463. * @param onLoad defines the callback to trigger once the texture is ready
  52464. * @param onError defines the callback to trigger in case of error
  52465. */
  52466. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52467. /**
  52468. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52469. * @param data contains the texture data
  52470. * @param texture defines the BabylonJS internal texture
  52471. * @param callback defines the method to call once ready to upload
  52472. */
  52473. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52474. }
  52475. }
  52476. declare module BABYLON {
  52477. /**
  52478. * Info about the .basis files
  52479. */
  52480. class BasisFileInfo {
  52481. /**
  52482. * If the file has alpha
  52483. */
  52484. hasAlpha: boolean;
  52485. /**
  52486. * Info about each image of the basis file
  52487. */
  52488. images: Array<{
  52489. levels: Array<{
  52490. width: number;
  52491. height: number;
  52492. transcodedPixels: ArrayBufferView;
  52493. }>;
  52494. }>;
  52495. }
  52496. /**
  52497. * Result of transcoding a basis file
  52498. */
  52499. class TranscodeResult {
  52500. /**
  52501. * Info about the .basis file
  52502. */
  52503. fileInfo: BasisFileInfo;
  52504. /**
  52505. * Format to use when loading the file
  52506. */
  52507. format: number;
  52508. }
  52509. /**
  52510. * Configuration options for the Basis transcoder
  52511. */
  52512. export class BasisTranscodeConfiguration {
  52513. /**
  52514. * Supported compression formats used to determine the supported output format of the transcoder
  52515. */
  52516. supportedCompressionFormats?: {
  52517. /**
  52518. * etc1 compression format
  52519. */
  52520. etc1?: boolean;
  52521. /**
  52522. * s3tc compression format
  52523. */
  52524. s3tc?: boolean;
  52525. /**
  52526. * pvrtc compression format
  52527. */
  52528. pvrtc?: boolean;
  52529. /**
  52530. * etc2 compression format
  52531. */
  52532. etc2?: boolean;
  52533. };
  52534. /**
  52535. * If mipmap levels should be loaded for transcoded images (Default: true)
  52536. */
  52537. loadMipmapLevels?: boolean;
  52538. /**
  52539. * Index of a single image to load (Default: all images)
  52540. */
  52541. loadSingleImage?: number;
  52542. }
  52543. /**
  52544. * Used to load .Basis files
  52545. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52546. */
  52547. export class BasisTools {
  52548. private static _IgnoreSupportedFormats;
  52549. /**
  52550. * URL to use when loading the basis transcoder
  52551. */
  52552. static JSModuleURL: string;
  52553. /**
  52554. * URL to use when loading the wasm module for the transcoder
  52555. */
  52556. static WasmModuleURL: string;
  52557. /**
  52558. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52559. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52560. * @returns internal format corresponding to the Basis format
  52561. */
  52562. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52563. private static _WorkerPromise;
  52564. private static _Worker;
  52565. private static _actionId;
  52566. private static _CreateWorkerAsync;
  52567. /**
  52568. * Transcodes a loaded image file to compressed pixel data
  52569. * @param imageData image data to transcode
  52570. * @param config configuration options for the transcoding
  52571. * @returns a promise resulting in the transcoded image
  52572. */
  52573. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52574. /**
  52575. * Loads a texture from the transcode result
  52576. * @param texture texture load to
  52577. * @param transcodeResult the result of transcoding the basis file to load from
  52578. */
  52579. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52580. }
  52581. }
  52582. declare module BABYLON {
  52583. /**
  52584. * Loader for .basis file format
  52585. */
  52586. export class _BasisTextureLoader implements IInternalTextureLoader {
  52587. /**
  52588. * Defines whether the loader supports cascade loading the different faces.
  52589. */
  52590. readonly supportCascades: boolean;
  52591. /**
  52592. * This returns if the loader support the current file information.
  52593. * @param extension defines the file extension of the file being loaded
  52594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52595. * @param fallback defines the fallback internal texture if any
  52596. * @param isBase64 defines whether the texture is encoded as a base64
  52597. * @param isBuffer defines whether the texture data are stored as a buffer
  52598. * @returns true if the loader can load the specified file
  52599. */
  52600. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52601. /**
  52602. * Transform the url before loading if required.
  52603. * @param rootUrl the url of the texture
  52604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52605. * @returns the transformed texture
  52606. */
  52607. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52608. /**
  52609. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52610. * @param rootUrl the url of the texture
  52611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52612. * @returns the fallback texture
  52613. */
  52614. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52615. /**
  52616. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52617. * @param data contains the texture data
  52618. * @param texture defines the BabylonJS internal texture
  52619. * @param createPolynomials will be true if polynomials have been requested
  52620. * @param onLoad defines the callback to trigger once the texture is ready
  52621. * @param onError defines the callback to trigger in case of error
  52622. */
  52623. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52624. /**
  52625. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52626. * @param data contains the texture data
  52627. * @param texture defines the BabylonJS internal texture
  52628. * @param callback defines the method to call once ready to upload
  52629. */
  52630. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52631. }
  52632. }
  52633. declare module BABYLON {
  52634. /**
  52635. * 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.
  52636. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52637. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52638. */
  52639. export class CustomProceduralTexture extends ProceduralTexture {
  52640. private _animate;
  52641. private _time;
  52642. private _config;
  52643. private _texturePath;
  52644. /**
  52645. * Instantiates a new Custom Procedural Texture.
  52646. * 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.
  52647. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52648. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52649. * @param name Define the name of the texture
  52650. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52651. * @param size Define the size of the texture to create
  52652. * @param scene Define the scene the texture belongs to
  52653. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52654. * @param generateMipMaps Define if the texture should creates mip maps or not
  52655. */
  52656. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52657. private _loadJson;
  52658. /**
  52659. * Is the texture ready to be used ? (rendered at least once)
  52660. * @returns true if ready, otherwise, false.
  52661. */
  52662. isReady(): boolean;
  52663. /**
  52664. * Render the texture to its associated render target.
  52665. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52666. */
  52667. render(useCameraPostProcess?: boolean): void;
  52668. /**
  52669. * Update the list of dependant textures samplers in the shader.
  52670. */
  52671. updateTextures(): void;
  52672. /**
  52673. * Update the uniform values of the procedural texture in the shader.
  52674. */
  52675. updateShaderUniforms(): void;
  52676. /**
  52677. * Define if the texture animates or not.
  52678. */
  52679. animate: boolean;
  52680. }
  52681. }
  52682. declare module BABYLON {
  52683. /** @hidden */
  52684. export var noisePixelShader: {
  52685. name: string;
  52686. shader: string;
  52687. };
  52688. }
  52689. declare module BABYLON {
  52690. /**
  52691. * Class used to generate noise procedural textures
  52692. */
  52693. export class NoiseProceduralTexture extends ProceduralTexture {
  52694. private _time;
  52695. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52696. brightness: number;
  52697. /** Defines the number of octaves to process */
  52698. octaves: number;
  52699. /** Defines the level of persistence (0.8 by default) */
  52700. persistence: number;
  52701. /** Gets or sets animation speed factor (default is 1) */
  52702. animationSpeedFactor: number;
  52703. /**
  52704. * Creates a new NoiseProceduralTexture
  52705. * @param name defines the name fo the texture
  52706. * @param size defines the size of the texture (default is 256)
  52707. * @param scene defines the hosting scene
  52708. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52709. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52710. */
  52711. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52712. private _updateShaderUniforms;
  52713. protected _getDefines(): string;
  52714. /** Generate the current state of the procedural texture */
  52715. render(useCameraPostProcess?: boolean): void;
  52716. /**
  52717. * Serializes this noise procedural texture
  52718. * @returns a serialized noise procedural texture object
  52719. */
  52720. serialize(): any;
  52721. /**
  52722. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52723. * @param parsedTexture defines parsed texture data
  52724. * @param scene defines the current scene
  52725. * @param rootUrl defines the root URL containing noise procedural texture information
  52726. * @returns a parsed NoiseProceduralTexture
  52727. */
  52728. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52729. }
  52730. }
  52731. declare module BABYLON {
  52732. /**
  52733. * Raw cube texture where the raw buffers are passed in
  52734. */
  52735. export class RawCubeTexture extends CubeTexture {
  52736. /**
  52737. * Creates a cube texture where the raw buffers are passed in.
  52738. * @param scene defines the scene the texture is attached to
  52739. * @param data defines the array of data to use to create each face
  52740. * @param size defines the size of the textures
  52741. * @param format defines the format of the data
  52742. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52743. * @param generateMipMaps defines if the engine should generate the mip levels
  52744. * @param invertY defines if data must be stored with Y axis inverted
  52745. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52746. * @param compression defines the compression used (null by default)
  52747. */
  52748. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52749. /**
  52750. * Updates the raw cube texture.
  52751. * @param data defines the data to store
  52752. * @param format defines the data format
  52753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52754. * @param invertY defines if data must be stored with Y axis inverted
  52755. * @param compression defines the compression used (null by default)
  52756. * @param level defines which level of the texture to update
  52757. */
  52758. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52759. /**
  52760. * Updates a raw cube texture with RGBD encoded data.
  52761. * @param data defines the array of data [mipmap][face] to use to create each face
  52762. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52765. * @returns a promsie that resolves when the operation is complete
  52766. */
  52767. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52768. /**
  52769. * Clones the raw cube texture.
  52770. * @return a new cube texture
  52771. */
  52772. clone(): CubeTexture;
  52773. /** @hidden */
  52774. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52775. }
  52776. }
  52777. declare module BABYLON {
  52778. /**
  52779. * Class used to store 3D textures containing user data
  52780. */
  52781. export class RawTexture3D extends Texture {
  52782. /** Gets or sets the texture format to use */
  52783. format: number;
  52784. private _engine;
  52785. /**
  52786. * Create a new RawTexture3D
  52787. * @param data defines the data of the texture
  52788. * @param width defines the width of the texture
  52789. * @param height defines the height of the texture
  52790. * @param depth defines the depth of the texture
  52791. * @param format defines the texture format to use
  52792. * @param scene defines the hosting scene
  52793. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52794. * @param invertY defines if texture must be stored with Y axis inverted
  52795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52796. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52797. */
  52798. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52799. /** Gets or sets the texture format to use */
  52800. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52801. /**
  52802. * Update the texture with new data
  52803. * @param data defines the data to store in the texture
  52804. */
  52805. update(data: ArrayBufferView): void;
  52806. }
  52807. }
  52808. declare module BABYLON {
  52809. /**
  52810. * Creates a refraction texture used by refraction channel of the standard material.
  52811. * It is like a mirror but to see through a material.
  52812. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52813. */
  52814. export class RefractionTexture extends RenderTargetTexture {
  52815. /**
  52816. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52817. * 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.
  52818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52819. */
  52820. refractionPlane: Plane;
  52821. /**
  52822. * Define how deep under the surface we should see.
  52823. */
  52824. depth: number;
  52825. /**
  52826. * Creates a refraction texture used by refraction channel of the standard material.
  52827. * It is like a mirror but to see through a material.
  52828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52829. * @param name Define the texture name
  52830. * @param size Define the size of the underlying texture
  52831. * @param scene Define the scene the refraction belongs to
  52832. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52833. */
  52834. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52835. /**
  52836. * Clone the refraction texture.
  52837. * @returns the cloned texture
  52838. */
  52839. clone(): RefractionTexture;
  52840. /**
  52841. * Serialize the texture to a JSON representation you could use in Parse later on
  52842. * @returns the serialized JSON representation
  52843. */
  52844. serialize(): any;
  52845. }
  52846. }
  52847. declare module BABYLON {
  52848. /**
  52849. * Defines the options related to the creation of an HtmlElementTexture
  52850. */
  52851. export interface IHtmlElementTextureOptions {
  52852. /**
  52853. * Defines wether mip maps should be created or not.
  52854. */
  52855. generateMipMaps?: boolean;
  52856. /**
  52857. * Defines the sampling mode of the texture.
  52858. */
  52859. samplingMode?: number;
  52860. /**
  52861. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52862. */
  52863. engine: Nullable<ThinEngine>;
  52864. /**
  52865. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52866. */
  52867. scene: Nullable<Scene>;
  52868. }
  52869. /**
  52870. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52871. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52872. * is automatically managed.
  52873. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52874. * in your application.
  52875. *
  52876. * As the update is not automatic, you need to call them manually.
  52877. */
  52878. export class HtmlElementTexture extends BaseTexture {
  52879. /**
  52880. * The texture URL.
  52881. */
  52882. element: HTMLVideoElement | HTMLCanvasElement;
  52883. private static readonly DefaultOptions;
  52884. private _textureMatrix;
  52885. private _engine;
  52886. private _isVideo;
  52887. private _generateMipMaps;
  52888. private _samplingMode;
  52889. /**
  52890. * Instantiates a HtmlElementTexture from the following parameters.
  52891. *
  52892. * @param name Defines the name of the texture
  52893. * @param element Defines the video or canvas the texture is filled with
  52894. * @param options Defines the other none mandatory texture creation options
  52895. */
  52896. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52897. private _createInternalTexture;
  52898. /**
  52899. * Returns the texture matrix used in most of the material.
  52900. */
  52901. getTextureMatrix(): Matrix;
  52902. /**
  52903. * Updates the content of the texture.
  52904. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52905. */
  52906. update(invertY?: Nullable<boolean>): void;
  52907. }
  52908. }
  52909. declare module BABYLON {
  52910. /**
  52911. * Enum used to define the target of a block
  52912. */
  52913. export enum NodeMaterialBlockTargets {
  52914. /** Vertex shader */
  52915. Vertex = 1,
  52916. /** Fragment shader */
  52917. Fragment = 2,
  52918. /** Neutral */
  52919. Neutral = 4,
  52920. /** Vertex and Fragment */
  52921. VertexAndFragment = 3
  52922. }
  52923. }
  52924. declare module BABYLON {
  52925. /**
  52926. * Defines the kind of connection point for node based material
  52927. */
  52928. export enum NodeMaterialBlockConnectionPointTypes {
  52929. /** Float */
  52930. Float = 1,
  52931. /** Int */
  52932. Int = 2,
  52933. /** Vector2 */
  52934. Vector2 = 4,
  52935. /** Vector3 */
  52936. Vector3 = 8,
  52937. /** Vector4 */
  52938. Vector4 = 16,
  52939. /** Color3 */
  52940. Color3 = 32,
  52941. /** Color4 */
  52942. Color4 = 64,
  52943. /** Matrix */
  52944. Matrix = 128,
  52945. /** Detect type based on connection */
  52946. AutoDetect = 1024,
  52947. /** Output type that will be defined by input type */
  52948. BasedOnInput = 2048
  52949. }
  52950. }
  52951. declare module BABYLON {
  52952. /**
  52953. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52954. */
  52955. export enum NodeMaterialBlockConnectionPointMode {
  52956. /** Value is an uniform */
  52957. Uniform = 0,
  52958. /** Value is a mesh attribute */
  52959. Attribute = 1,
  52960. /** Value is a varying between vertex and fragment shaders */
  52961. Varying = 2,
  52962. /** Mode is undefined */
  52963. Undefined = 3
  52964. }
  52965. }
  52966. declare module BABYLON {
  52967. /**
  52968. * Enum used to define system values e.g. values automatically provided by the system
  52969. */
  52970. export enum NodeMaterialSystemValues {
  52971. /** World */
  52972. World = 1,
  52973. /** View */
  52974. View = 2,
  52975. /** Projection */
  52976. Projection = 3,
  52977. /** ViewProjection */
  52978. ViewProjection = 4,
  52979. /** WorldView */
  52980. WorldView = 5,
  52981. /** WorldViewProjection */
  52982. WorldViewProjection = 6,
  52983. /** CameraPosition */
  52984. CameraPosition = 7,
  52985. /** Fog Color */
  52986. FogColor = 8,
  52987. /** Delta time */
  52988. DeltaTime = 9
  52989. }
  52990. }
  52991. declare module BABYLON {
  52992. /**
  52993. * Root class for all node material optimizers
  52994. */
  52995. export class NodeMaterialOptimizer {
  52996. /**
  52997. * Function used to optimize a NodeMaterial graph
  52998. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52999. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53000. */
  53001. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53002. }
  53003. }
  53004. declare module BABYLON {
  53005. /**
  53006. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53007. */
  53008. export class TransformBlock extends NodeMaterialBlock {
  53009. /**
  53010. * Defines the value to use to complement W value to transform it to a Vector4
  53011. */
  53012. complementW: number;
  53013. /**
  53014. * Defines the value to use to complement z value to transform it to a Vector4
  53015. */
  53016. complementZ: number;
  53017. /**
  53018. * Creates a new TransformBlock
  53019. * @param name defines the block name
  53020. */
  53021. constructor(name: string);
  53022. /**
  53023. * Gets the current class name
  53024. * @returns the class name
  53025. */
  53026. getClassName(): string;
  53027. /**
  53028. * Gets the vector input
  53029. */
  53030. readonly vector: NodeMaterialConnectionPoint;
  53031. /**
  53032. * Gets the output component
  53033. */
  53034. readonly output: NodeMaterialConnectionPoint;
  53035. /**
  53036. * Gets the matrix transform input
  53037. */
  53038. readonly transform: NodeMaterialConnectionPoint;
  53039. protected _buildBlock(state: NodeMaterialBuildState): this;
  53040. serialize(): any;
  53041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53042. protected _dumpPropertiesCode(): string;
  53043. }
  53044. }
  53045. declare module BABYLON {
  53046. /**
  53047. * Block used to output the vertex position
  53048. */
  53049. export class VertexOutputBlock extends NodeMaterialBlock {
  53050. /**
  53051. * Creates a new VertexOutputBlock
  53052. * @param name defines the block name
  53053. */
  53054. constructor(name: string);
  53055. /**
  53056. * Gets the current class name
  53057. * @returns the class name
  53058. */
  53059. getClassName(): string;
  53060. /**
  53061. * Gets the vector input component
  53062. */
  53063. readonly vector: NodeMaterialConnectionPoint;
  53064. protected _buildBlock(state: NodeMaterialBuildState): this;
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Block used to output the final color
  53070. */
  53071. export class FragmentOutputBlock extends NodeMaterialBlock {
  53072. /**
  53073. * Create a new FragmentOutputBlock
  53074. * @param name defines the block name
  53075. */
  53076. constructor(name: string);
  53077. /**
  53078. * Gets the current class name
  53079. * @returns the class name
  53080. */
  53081. getClassName(): string;
  53082. /**
  53083. * Gets the rgba input component
  53084. */
  53085. readonly rgba: NodeMaterialConnectionPoint;
  53086. /**
  53087. * Gets the rgb input component
  53088. */
  53089. readonly rgb: NodeMaterialConnectionPoint;
  53090. /**
  53091. * Gets the a input component
  53092. */
  53093. readonly a: NodeMaterialConnectionPoint;
  53094. protected _buildBlock(state: NodeMaterialBuildState): this;
  53095. }
  53096. }
  53097. declare module BABYLON {
  53098. /**
  53099. * Block used to read a reflection texture from a sampler
  53100. */
  53101. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53102. private _define3DName;
  53103. private _defineCubicName;
  53104. private _defineExplicitName;
  53105. private _defineProjectionName;
  53106. private _defineLocalCubicName;
  53107. private _defineSphericalName;
  53108. private _definePlanarName;
  53109. private _defineEquirectangularName;
  53110. private _defineMirroredEquirectangularFixedName;
  53111. private _defineEquirectangularFixedName;
  53112. private _defineSkyboxName;
  53113. private _cubeSamplerName;
  53114. private _2DSamplerName;
  53115. private _positionUVWName;
  53116. private _directionWName;
  53117. private _reflectionCoordsName;
  53118. private _reflection2DCoordsName;
  53119. private _reflectionColorName;
  53120. private _reflectionMatrixName;
  53121. /**
  53122. * Gets or sets the texture associated with the node
  53123. */
  53124. texture: Nullable<BaseTexture>;
  53125. /**
  53126. * Create a new TextureBlock
  53127. * @param name defines the block name
  53128. */
  53129. constructor(name: string);
  53130. /**
  53131. * Gets the current class name
  53132. * @returns the class name
  53133. */
  53134. getClassName(): string;
  53135. /**
  53136. * Gets the world position input component
  53137. */
  53138. readonly position: NodeMaterialConnectionPoint;
  53139. /**
  53140. * Gets the world position input component
  53141. */
  53142. readonly worldPosition: NodeMaterialConnectionPoint;
  53143. /**
  53144. * Gets the world normal input component
  53145. */
  53146. readonly worldNormal: NodeMaterialConnectionPoint;
  53147. /**
  53148. * Gets the world input component
  53149. */
  53150. readonly world: NodeMaterialConnectionPoint;
  53151. /**
  53152. * Gets the camera (or eye) position component
  53153. */
  53154. readonly cameraPosition: NodeMaterialConnectionPoint;
  53155. /**
  53156. * Gets the view input component
  53157. */
  53158. readonly view: NodeMaterialConnectionPoint;
  53159. /**
  53160. * Gets the rgb output component
  53161. */
  53162. readonly rgb: NodeMaterialConnectionPoint;
  53163. /**
  53164. * Gets the r output component
  53165. */
  53166. readonly r: NodeMaterialConnectionPoint;
  53167. /**
  53168. * Gets the g output component
  53169. */
  53170. readonly g: NodeMaterialConnectionPoint;
  53171. /**
  53172. * Gets the b output component
  53173. */
  53174. readonly b: NodeMaterialConnectionPoint;
  53175. autoConfigure(material: NodeMaterial): void;
  53176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53177. isReady(): boolean;
  53178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53179. private _injectVertexCode;
  53180. private _writeOutput;
  53181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53182. protected _dumpPropertiesCode(): string;
  53183. serialize(): any;
  53184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53185. }
  53186. }
  53187. declare module BABYLON {
  53188. /**
  53189. * Interface used to configure the node material editor
  53190. */
  53191. export interface INodeMaterialEditorOptions {
  53192. /** Define the URl to load node editor script */
  53193. editorURL?: string;
  53194. }
  53195. /** @hidden */
  53196. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53197. /** BONES */
  53198. NUM_BONE_INFLUENCERS: number;
  53199. BonesPerMesh: number;
  53200. BONETEXTURE: boolean;
  53201. /** MORPH TARGETS */
  53202. MORPHTARGETS: boolean;
  53203. MORPHTARGETS_NORMAL: boolean;
  53204. MORPHTARGETS_TANGENT: boolean;
  53205. MORPHTARGETS_UV: boolean;
  53206. NUM_MORPH_INFLUENCERS: number;
  53207. /** IMAGE PROCESSING */
  53208. IMAGEPROCESSING: boolean;
  53209. VIGNETTE: boolean;
  53210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53211. VIGNETTEBLENDMODEOPAQUE: boolean;
  53212. TONEMAPPING: boolean;
  53213. TONEMAPPING_ACES: boolean;
  53214. CONTRAST: boolean;
  53215. EXPOSURE: boolean;
  53216. COLORCURVES: boolean;
  53217. COLORGRADING: boolean;
  53218. COLORGRADING3D: boolean;
  53219. SAMPLER3DGREENDEPTH: boolean;
  53220. SAMPLER3DBGRMAP: boolean;
  53221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53222. /** MISC. */
  53223. BUMPDIRECTUV: number;
  53224. constructor();
  53225. setValue(name: string, value: boolean): void;
  53226. }
  53227. /**
  53228. * Class used to configure NodeMaterial
  53229. */
  53230. export interface INodeMaterialOptions {
  53231. /**
  53232. * Defines if blocks should emit comments
  53233. */
  53234. emitComments: boolean;
  53235. }
  53236. /**
  53237. * Class used to create a node based material built by assembling shader blocks
  53238. */
  53239. export class NodeMaterial extends PushMaterial {
  53240. private static _BuildIdGenerator;
  53241. private _options;
  53242. private _vertexCompilationState;
  53243. private _fragmentCompilationState;
  53244. private _sharedData;
  53245. private _buildId;
  53246. private _buildWasSuccessful;
  53247. private _cachedWorldViewMatrix;
  53248. private _cachedWorldViewProjectionMatrix;
  53249. private _optimizers;
  53250. private _animationFrame;
  53251. /** Define the URl to load node editor script */
  53252. static EditorURL: string;
  53253. private BJSNODEMATERIALEDITOR;
  53254. /** Get the inspector from bundle or global */
  53255. private _getGlobalNodeMaterialEditor;
  53256. /**
  53257. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  53258. */
  53259. ignoreAlpha: boolean;
  53260. /**
  53261. * Defines the maximum number of lights that can be used in the material
  53262. */
  53263. maxSimultaneousLights: number;
  53264. /**
  53265. * Observable raised when the material is built
  53266. */
  53267. onBuildObservable: Observable<NodeMaterial>;
  53268. /**
  53269. * Gets or sets the root nodes of the material vertex shader
  53270. */
  53271. _vertexOutputNodes: NodeMaterialBlock[];
  53272. /**
  53273. * Gets or sets the root nodes of the material fragment (pixel) shader
  53274. */
  53275. _fragmentOutputNodes: NodeMaterialBlock[];
  53276. /** Gets or sets options to control the node material overall behavior */
  53277. options: INodeMaterialOptions;
  53278. /**
  53279. * Default configuration related to image processing available in the standard Material.
  53280. */
  53281. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53282. /**
  53283. * Gets the image processing configuration used either in this material.
  53284. */
  53285. /**
  53286. * Sets the Default image processing configuration used either in the this material.
  53287. *
  53288. * If sets to null, the scene one is in use.
  53289. */
  53290. imageProcessingConfiguration: ImageProcessingConfiguration;
  53291. /**
  53292. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53293. */
  53294. attachedBlocks: NodeMaterialBlock[];
  53295. /**
  53296. * Create a new node based material
  53297. * @param name defines the material name
  53298. * @param scene defines the hosting scene
  53299. * @param options defines creation option
  53300. */
  53301. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53302. /**
  53303. * Gets the current class name of the material e.g. "NodeMaterial"
  53304. * @returns the class name
  53305. */
  53306. getClassName(): string;
  53307. /**
  53308. * Keep track of the image processing observer to allow dispose and replace.
  53309. */
  53310. private _imageProcessingObserver;
  53311. /**
  53312. * Attaches a new image processing configuration to the Standard Material.
  53313. * @param configuration
  53314. */
  53315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53316. /**
  53317. * Get a block by its name
  53318. * @param name defines the name of the block to retrieve
  53319. * @returns the required block or null if not found
  53320. */
  53321. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53322. /**
  53323. * Get a block by its name
  53324. * @param predicate defines the predicate used to find the good candidate
  53325. * @returns the required block or null if not found
  53326. */
  53327. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53328. /**
  53329. * Get an input block by its name
  53330. * @param predicate defines the predicate used to find the good candidate
  53331. * @returns the required input block or null if not found
  53332. */
  53333. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53334. /**
  53335. * Gets the list of input blocks attached to this material
  53336. * @returns an array of InputBlocks
  53337. */
  53338. getInputBlocks(): InputBlock[];
  53339. /**
  53340. * Adds a new optimizer to the list of optimizers
  53341. * @param optimizer defines the optimizers to add
  53342. * @returns the current material
  53343. */
  53344. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53345. /**
  53346. * Remove an optimizer from the list of optimizers
  53347. * @param optimizer defines the optimizers to remove
  53348. * @returns the current material
  53349. */
  53350. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53351. /**
  53352. * Add a new block to the list of output nodes
  53353. * @param node defines the node to add
  53354. * @returns the current material
  53355. */
  53356. addOutputNode(node: NodeMaterialBlock): this;
  53357. /**
  53358. * Remove a block from the list of root nodes
  53359. * @param node defines the node to remove
  53360. * @returns the current material
  53361. */
  53362. removeOutputNode(node: NodeMaterialBlock): this;
  53363. private _addVertexOutputNode;
  53364. private _removeVertexOutputNode;
  53365. private _addFragmentOutputNode;
  53366. private _removeFragmentOutputNode;
  53367. /**
  53368. * Specifies if the material will require alpha blending
  53369. * @returns a boolean specifying if alpha blending is needed
  53370. */
  53371. needAlphaBlending(): boolean;
  53372. /**
  53373. * Specifies if this material should be rendered in alpha test mode
  53374. * @returns a boolean specifying if an alpha test is needed.
  53375. */
  53376. needAlphaTesting(): boolean;
  53377. private _initializeBlock;
  53378. private _resetDualBlocks;
  53379. /**
  53380. * Build the material and generates the inner effect
  53381. * @param verbose defines if the build should log activity
  53382. */
  53383. build(verbose?: boolean): void;
  53384. /**
  53385. * Runs an otpimization phase to try to improve the shader code
  53386. */
  53387. optimize(): void;
  53388. private _prepareDefinesForAttributes;
  53389. /**
  53390. * Get if the submesh is ready to be used and all its information available.
  53391. * Child classes can use it to update shaders
  53392. * @param mesh defines the mesh to check
  53393. * @param subMesh defines which submesh to check
  53394. * @param useInstances specifies that instances should be used
  53395. * @returns a boolean indicating that the submesh is ready or not
  53396. */
  53397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53398. /**
  53399. * Get a string representing the shaders built by the current node graph
  53400. */
  53401. readonly compiledShaders: string;
  53402. /**
  53403. * Binds the world matrix to the material
  53404. * @param world defines the world transformation matrix
  53405. */
  53406. bindOnlyWorldMatrix(world: Matrix): void;
  53407. /**
  53408. * Binds the submesh to this material by preparing the effect and shader to draw
  53409. * @param world defines the world transformation matrix
  53410. * @param mesh defines the mesh containing the submesh
  53411. * @param subMesh defines the submesh to bind the material to
  53412. */
  53413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53414. /**
  53415. * Gets the active textures from the material
  53416. * @returns an array of textures
  53417. */
  53418. getActiveTextures(): BaseTexture[];
  53419. /**
  53420. * Gets the list of texture blocks
  53421. * @returns an array of texture blocks
  53422. */
  53423. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53424. /**
  53425. * Specifies if the material uses a texture
  53426. * @param texture defines the texture to check against the material
  53427. * @returns a boolean specifying if the material uses the texture
  53428. */
  53429. hasTexture(texture: BaseTexture): boolean;
  53430. /**
  53431. * Disposes the material
  53432. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53433. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53434. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53435. */
  53436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53437. /** Creates the node editor window. */
  53438. private _createNodeEditor;
  53439. /**
  53440. * Launch the node material editor
  53441. * @param config Define the configuration of the editor
  53442. * @return a promise fulfilled when the node editor is visible
  53443. */
  53444. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53445. /**
  53446. * Clear the current material
  53447. */
  53448. clear(): void;
  53449. /**
  53450. * Clear the current material and set it to a default state
  53451. */
  53452. setToDefault(): void;
  53453. /**
  53454. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53455. * @param url defines the url to load from
  53456. * @returns a promise that will fullfil when the material is fully loaded
  53457. */
  53458. loadAsync(url: string): Promise<void>;
  53459. private _gatherBlocks;
  53460. /**
  53461. * Generate a string containing the code declaration required to create an equivalent of this material
  53462. * @returns a string
  53463. */
  53464. generateCode(): string;
  53465. /**
  53466. * Serializes this material in a JSON representation
  53467. * @returns the serialized material object
  53468. */
  53469. serialize(): any;
  53470. private _restoreConnections;
  53471. /**
  53472. * Clear the current graph and load a new one from a serialization object
  53473. * @param source defines the JSON representation of the material
  53474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53475. */
  53476. loadFromSerialization(source: any, rootUrl?: string): void;
  53477. /**
  53478. * Creates a node material from parsed material data
  53479. * @param source defines the JSON representation of the material
  53480. * @param scene defines the hosting scene
  53481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53482. * @returns a new node material
  53483. */
  53484. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53485. /**
  53486. * Creates a new node material set to default basic configuration
  53487. * @param name defines the name of the material
  53488. * @param scene defines the hosting scene
  53489. * @returns a new NodeMaterial
  53490. */
  53491. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53492. }
  53493. }
  53494. declare module BABYLON {
  53495. /**
  53496. * Block used to read a texture from a sampler
  53497. */
  53498. export class TextureBlock extends NodeMaterialBlock {
  53499. private _defineName;
  53500. private _linearDefineName;
  53501. private _samplerName;
  53502. private _transformedUVName;
  53503. private _textureTransformName;
  53504. private _textureInfoName;
  53505. private _mainUVName;
  53506. private _mainUVDefineName;
  53507. /**
  53508. * Gets or sets the texture associated with the node
  53509. */
  53510. texture: Nullable<Texture>;
  53511. /**
  53512. * Create a new TextureBlock
  53513. * @param name defines the block name
  53514. */
  53515. constructor(name: string);
  53516. /**
  53517. * Gets the current class name
  53518. * @returns the class name
  53519. */
  53520. getClassName(): string;
  53521. /**
  53522. * Gets the uv input component
  53523. */
  53524. readonly uv: NodeMaterialConnectionPoint;
  53525. /**
  53526. * Gets the rgba output component
  53527. */
  53528. readonly rgba: NodeMaterialConnectionPoint;
  53529. /**
  53530. * Gets the rgb output component
  53531. */
  53532. readonly rgb: NodeMaterialConnectionPoint;
  53533. /**
  53534. * Gets the r output component
  53535. */
  53536. readonly r: NodeMaterialConnectionPoint;
  53537. /**
  53538. * Gets the g output component
  53539. */
  53540. readonly g: NodeMaterialConnectionPoint;
  53541. /**
  53542. * Gets the b output component
  53543. */
  53544. readonly b: NodeMaterialConnectionPoint;
  53545. /**
  53546. * Gets the a output component
  53547. */
  53548. readonly a: NodeMaterialConnectionPoint;
  53549. readonly target: NodeMaterialBlockTargets;
  53550. autoConfigure(material: NodeMaterial): void;
  53551. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53553. isReady(): boolean;
  53554. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53555. private readonly _isMixed;
  53556. private _injectVertexCode;
  53557. private _writeOutput;
  53558. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53559. protected _dumpPropertiesCode(): string;
  53560. serialize(): any;
  53561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53562. }
  53563. }
  53564. declare module BABYLON {
  53565. /**
  53566. * Class used to store shared data between 2 NodeMaterialBuildState
  53567. */
  53568. export class NodeMaterialBuildStateSharedData {
  53569. /**
  53570. * Gets the list of emitted varyings
  53571. */
  53572. temps: string[];
  53573. /**
  53574. * Gets the list of emitted varyings
  53575. */
  53576. varyings: string[];
  53577. /**
  53578. * Gets the varying declaration string
  53579. */
  53580. varyingDeclaration: string;
  53581. /**
  53582. * Input blocks
  53583. */
  53584. inputBlocks: InputBlock[];
  53585. /**
  53586. * Input blocks
  53587. */
  53588. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53589. /**
  53590. * Bindable blocks (Blocks that need to set data to the effect)
  53591. */
  53592. bindableBlocks: NodeMaterialBlock[];
  53593. /**
  53594. * List of blocks that can provide a compilation fallback
  53595. */
  53596. blocksWithFallbacks: NodeMaterialBlock[];
  53597. /**
  53598. * List of blocks that can provide a define update
  53599. */
  53600. blocksWithDefines: NodeMaterialBlock[];
  53601. /**
  53602. * List of blocks that can provide a repeatable content
  53603. */
  53604. repeatableContentBlocks: NodeMaterialBlock[];
  53605. /**
  53606. * List of blocks that can provide a dynamic list of uniforms
  53607. */
  53608. dynamicUniformBlocks: NodeMaterialBlock[];
  53609. /**
  53610. * List of blocks that can block the isReady function for the material
  53611. */
  53612. blockingBlocks: NodeMaterialBlock[];
  53613. /**
  53614. * Gets the list of animated inputs
  53615. */
  53616. animatedInputs: InputBlock[];
  53617. /**
  53618. * Build Id used to avoid multiple recompilations
  53619. */
  53620. buildId: number;
  53621. /** List of emitted variables */
  53622. variableNames: {
  53623. [key: string]: number;
  53624. };
  53625. /** List of emitted defines */
  53626. defineNames: {
  53627. [key: string]: number;
  53628. };
  53629. /** Should emit comments? */
  53630. emitComments: boolean;
  53631. /** Emit build activity */
  53632. verbose: boolean;
  53633. /** Gets or sets the hosting scene */
  53634. scene: Scene;
  53635. /**
  53636. * Gets the compilation hints emitted at compilation time
  53637. */
  53638. hints: {
  53639. needWorldViewMatrix: boolean;
  53640. needWorldViewProjectionMatrix: boolean;
  53641. needAlphaBlending: boolean;
  53642. needAlphaTesting: boolean;
  53643. };
  53644. /**
  53645. * List of compilation checks
  53646. */
  53647. checks: {
  53648. emitVertex: boolean;
  53649. emitFragment: boolean;
  53650. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53651. };
  53652. /** Creates a new shared data */
  53653. constructor();
  53654. /**
  53655. * Emits console errors and exceptions if there is a failing check
  53656. */
  53657. emitErrors(): void;
  53658. }
  53659. }
  53660. declare module BABYLON {
  53661. /**
  53662. * Class used to store node based material build state
  53663. */
  53664. export class NodeMaterialBuildState {
  53665. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53666. supportUniformBuffers: boolean;
  53667. /**
  53668. * Gets the list of emitted attributes
  53669. */
  53670. attributes: string[];
  53671. /**
  53672. * Gets the list of emitted uniforms
  53673. */
  53674. uniforms: string[];
  53675. /**
  53676. * Gets the list of emitted constants
  53677. */
  53678. constants: string[];
  53679. /**
  53680. * Gets the list of emitted samplers
  53681. */
  53682. samplers: string[];
  53683. /**
  53684. * Gets the list of emitted functions
  53685. */
  53686. functions: {
  53687. [key: string]: string;
  53688. };
  53689. /**
  53690. * Gets the list of emitted extensions
  53691. */
  53692. extensions: {
  53693. [key: string]: string;
  53694. };
  53695. /**
  53696. * Gets the target of the compilation state
  53697. */
  53698. target: NodeMaterialBlockTargets;
  53699. /**
  53700. * Gets the list of emitted counters
  53701. */
  53702. counters: {
  53703. [key: string]: number;
  53704. };
  53705. /**
  53706. * Shared data between multiple NodeMaterialBuildState instances
  53707. */
  53708. sharedData: NodeMaterialBuildStateSharedData;
  53709. /** @hidden */
  53710. _vertexState: NodeMaterialBuildState;
  53711. /** @hidden */
  53712. _attributeDeclaration: string;
  53713. /** @hidden */
  53714. _uniformDeclaration: string;
  53715. /** @hidden */
  53716. _constantDeclaration: string;
  53717. /** @hidden */
  53718. _samplerDeclaration: string;
  53719. /** @hidden */
  53720. _varyingTransfer: string;
  53721. private _repeatableContentAnchorIndex;
  53722. /** @hidden */
  53723. _builtCompilationString: string;
  53724. /**
  53725. * Gets the emitted compilation strings
  53726. */
  53727. compilationString: string;
  53728. /**
  53729. * Finalize the compilation strings
  53730. * @param state defines the current compilation state
  53731. */
  53732. finalize(state: NodeMaterialBuildState): void;
  53733. /** @hidden */
  53734. readonly _repeatableContentAnchor: string;
  53735. /** @hidden */
  53736. _getFreeVariableName(prefix: string): string;
  53737. /** @hidden */
  53738. _getFreeDefineName(prefix: string): string;
  53739. /** @hidden */
  53740. _excludeVariableName(name: string): void;
  53741. /** @hidden */
  53742. _emit2DSampler(name: string): void;
  53743. /** @hidden */
  53744. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53745. /** @hidden */
  53746. _emitExtension(name: string, extension: string): void;
  53747. /** @hidden */
  53748. _emitFunction(name: string, code: string, comments: string): void;
  53749. /** @hidden */
  53750. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53751. replaceStrings?: {
  53752. search: RegExp;
  53753. replace: string;
  53754. }[];
  53755. repeatKey?: string;
  53756. }): string;
  53757. /** @hidden */
  53758. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53759. repeatKey?: string;
  53760. removeAttributes?: boolean;
  53761. removeUniforms?: boolean;
  53762. removeVaryings?: boolean;
  53763. removeIfDef?: boolean;
  53764. replaceStrings?: {
  53765. search: RegExp;
  53766. replace: string;
  53767. }[];
  53768. }, storeKey?: string): void;
  53769. /** @hidden */
  53770. _registerTempVariable(name: string): boolean;
  53771. /** @hidden */
  53772. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53773. /** @hidden */
  53774. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53775. /** @hidden */
  53776. _emitFloat(value: number): string;
  53777. }
  53778. }
  53779. declare module BABYLON {
  53780. /**
  53781. * Defines a block that can be used inside a node based material
  53782. */
  53783. export class NodeMaterialBlock {
  53784. private _buildId;
  53785. private _buildTarget;
  53786. private _target;
  53787. private _isFinalMerger;
  53788. private _isInput;
  53789. /** @hidden */
  53790. _codeVariableName: string;
  53791. /** @hidden */
  53792. _inputs: NodeMaterialConnectionPoint[];
  53793. /** @hidden */
  53794. _outputs: NodeMaterialConnectionPoint[];
  53795. /** @hidden */
  53796. _preparationId: number;
  53797. /**
  53798. * Gets or sets the name of the block
  53799. */
  53800. name: string;
  53801. /**
  53802. * Gets or sets the unique id of the node
  53803. */
  53804. uniqueId: number;
  53805. /**
  53806. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53807. */
  53808. readonly isFinalMerger: boolean;
  53809. /**
  53810. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53811. */
  53812. readonly isInput: boolean;
  53813. /**
  53814. * Gets or sets the build Id
  53815. */
  53816. buildId: number;
  53817. /**
  53818. * Gets or sets the target of the block
  53819. */
  53820. target: NodeMaterialBlockTargets;
  53821. /**
  53822. * Gets the list of input points
  53823. */
  53824. readonly inputs: NodeMaterialConnectionPoint[];
  53825. /** Gets the list of output points */
  53826. readonly outputs: NodeMaterialConnectionPoint[];
  53827. /**
  53828. * Find an input by its name
  53829. * @param name defines the name of the input to look for
  53830. * @returns the input or null if not found
  53831. */
  53832. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53833. /**
  53834. * Find an output by its name
  53835. * @param name defines the name of the outputto look for
  53836. * @returns the output or null if not found
  53837. */
  53838. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53839. /**
  53840. * Creates a new NodeMaterialBlock
  53841. * @param name defines the block name
  53842. * @param target defines the target of that block (Vertex by default)
  53843. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53844. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53845. */
  53846. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53847. /**
  53848. * Initialize the block and prepare the context for build
  53849. * @param state defines the state that will be used for the build
  53850. */
  53851. initialize(state: NodeMaterialBuildState): void;
  53852. /**
  53853. * Bind data to effect. Will only be called for blocks with isBindable === true
  53854. * @param effect defines the effect to bind data to
  53855. * @param nodeMaterial defines the hosting NodeMaterial
  53856. * @param mesh defines the mesh that will be rendered
  53857. */
  53858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53859. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53860. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53861. protected _writeFloat(value: number): string;
  53862. /**
  53863. * Gets the current class name e.g. "NodeMaterialBlock"
  53864. * @returns the class name
  53865. */
  53866. getClassName(): string;
  53867. /**
  53868. * Register a new input. Must be called inside a block constructor
  53869. * @param name defines the connection point name
  53870. * @param type defines the connection point type
  53871. * @param isOptional defines a boolean indicating that this input can be omitted
  53872. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53873. * @returns the current block
  53874. */
  53875. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53876. /**
  53877. * Register a new output. Must be called inside a block constructor
  53878. * @param name defines the connection point name
  53879. * @param type defines the connection point type
  53880. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53881. * @returns the current block
  53882. */
  53883. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53884. /**
  53885. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53886. * @param forOutput defines an optional connection point to check compatibility with
  53887. * @returns the first available input or null
  53888. */
  53889. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53890. /**
  53891. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53892. * @param forBlock defines an optional block to check compatibility with
  53893. * @returns the first available input or null
  53894. */
  53895. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53896. /**
  53897. * Gets the sibling of the given output
  53898. * @param current defines the current output
  53899. * @returns the next output in the list or null
  53900. */
  53901. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53902. /**
  53903. * Connect current block with another block
  53904. * @param other defines the block to connect with
  53905. * @param options define the various options to help pick the right connections
  53906. * @returns the current block
  53907. */
  53908. connectTo(other: NodeMaterialBlock, options?: {
  53909. input?: string;
  53910. output?: string;
  53911. outputSwizzle?: string;
  53912. }): this | undefined;
  53913. protected _buildBlock(state: NodeMaterialBuildState): void;
  53914. /**
  53915. * Add uniforms, samplers and uniform buffers at compilation time
  53916. * @param state defines the state to update
  53917. * @param nodeMaterial defines the node material requesting the update
  53918. * @param defines defines the material defines to update
  53919. * @param uniformBuffers defines the list of uniform buffer names
  53920. */
  53921. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53922. /**
  53923. * Add potential fallbacks if shader compilation fails
  53924. * @param mesh defines the mesh to be rendered
  53925. * @param fallbacks defines the current prioritized list of fallbacks
  53926. */
  53927. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53928. /**
  53929. * Initialize defines for shader compilation
  53930. * @param mesh defines the mesh to be rendered
  53931. * @param nodeMaterial defines the node material requesting the update
  53932. * @param defines defines the material defines to update
  53933. * @param useInstances specifies that instances should be used
  53934. */
  53935. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53936. /**
  53937. * Update defines for shader compilation
  53938. * @param mesh defines the mesh to be rendered
  53939. * @param nodeMaterial defines the node material requesting the update
  53940. * @param defines defines the material defines to update
  53941. * @param useInstances specifies that instances should be used
  53942. */
  53943. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53944. /**
  53945. * Lets the block try to connect some inputs automatically
  53946. * @param material defines the hosting NodeMaterial
  53947. */
  53948. autoConfigure(material: NodeMaterial): void;
  53949. /**
  53950. * Function called when a block is declared as repeatable content generator
  53951. * @param vertexShaderState defines the current compilation state for the vertex shader
  53952. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53953. * @param mesh defines the mesh to be rendered
  53954. * @param defines defines the material defines to update
  53955. */
  53956. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53957. /**
  53958. * Checks if the block is ready
  53959. * @param mesh defines the mesh to be rendered
  53960. * @param nodeMaterial defines the node material requesting the update
  53961. * @param defines defines the material defines to update
  53962. * @param useInstances specifies that instances should be used
  53963. * @returns true if the block is ready
  53964. */
  53965. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53966. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53967. private _processBuild;
  53968. /**
  53969. * Compile the current node and generate the shader code
  53970. * @param state defines the current compilation state (uniforms, samplers, current string)
  53971. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53972. * @returns true if already built
  53973. */
  53974. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53975. protected _inputRename(name: string): string;
  53976. protected _outputRename(name: string): string;
  53977. protected _dumpPropertiesCode(): string;
  53978. /** @hidden */
  53979. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53980. /** @hidden */
  53981. _dumpCodeForOutputConnections(): string;
  53982. /**
  53983. * Clone the current block to a new identical block
  53984. * @param scene defines the hosting scene
  53985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53986. * @returns a copy of the current block
  53987. */
  53988. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53989. /**
  53990. * Serializes this block in a JSON representation
  53991. * @returns the serialized block object
  53992. */
  53993. serialize(): any;
  53994. /** @hidden */
  53995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53996. /**
  53997. * Release resources
  53998. */
  53999. dispose(): void;
  54000. }
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * Enum defining the type of animations supported by InputBlock
  54005. */
  54006. export enum AnimatedInputBlockTypes {
  54007. /** No animation */
  54008. None = 0,
  54009. /** Time based animation. Will only work for floats */
  54010. Time = 1
  54011. }
  54012. }
  54013. declare module BABYLON {
  54014. /**
  54015. * Block used to expose an input value
  54016. */
  54017. export class InputBlock extends NodeMaterialBlock {
  54018. private _mode;
  54019. private _associatedVariableName;
  54020. private _storedValue;
  54021. private _valueCallback;
  54022. private _type;
  54023. private _animationType;
  54024. /** Gets or set a value used to limit the range of float values */
  54025. min: number;
  54026. /** Gets or set a value used to limit the range of float values */
  54027. max: number;
  54028. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54029. matrixMode: number;
  54030. /** @hidden */
  54031. _systemValue: Nullable<NodeMaterialSystemValues>;
  54032. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54033. visibleInInspector: boolean;
  54034. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54035. isConstant: boolean;
  54036. /**
  54037. * Gets or sets the connection point type (default is float)
  54038. */
  54039. readonly type: NodeMaterialBlockConnectionPointTypes;
  54040. /**
  54041. * Creates a new InputBlock
  54042. * @param name defines the block name
  54043. * @param target defines the target of that block (Vertex by default)
  54044. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54045. */
  54046. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54047. /**
  54048. * Gets the output component
  54049. */
  54050. readonly output: NodeMaterialConnectionPoint;
  54051. /**
  54052. * Set the source of this connection point to a vertex attribute
  54053. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54054. * @returns the current connection point
  54055. */
  54056. setAsAttribute(attributeName?: string): InputBlock;
  54057. /**
  54058. * Set the source of this connection point to a system value
  54059. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54060. * @returns the current connection point
  54061. */
  54062. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54063. /**
  54064. * Gets or sets the value of that point.
  54065. * Please note that this value will be ignored if valueCallback is defined
  54066. */
  54067. value: any;
  54068. /**
  54069. * Gets or sets a callback used to get the value of that point.
  54070. * Please note that setting this value will force the connection point to ignore the value property
  54071. */
  54072. valueCallback: () => any;
  54073. /**
  54074. * Gets or sets the associated variable name in the shader
  54075. */
  54076. associatedVariableName: string;
  54077. /** Gets or sets the type of animation applied to the input */
  54078. animationType: AnimatedInputBlockTypes;
  54079. /**
  54080. * Gets a boolean indicating that this connection point not defined yet
  54081. */
  54082. readonly isUndefined: boolean;
  54083. /**
  54084. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54085. * In this case the connection point name must be the name of the uniform to use.
  54086. * Can only be set on inputs
  54087. */
  54088. isUniform: boolean;
  54089. /**
  54090. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54091. * In this case the connection point name must be the name of the attribute to use
  54092. * Can only be set on inputs
  54093. */
  54094. isAttribute: boolean;
  54095. /**
  54096. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54097. * Can only be set on exit points
  54098. */
  54099. isVarying: boolean;
  54100. /**
  54101. * Gets a boolean indicating that the current connection point is a system value
  54102. */
  54103. readonly isSystemValue: boolean;
  54104. /**
  54105. * Gets or sets the current well known value or null if not defined as a system value
  54106. */
  54107. systemValue: Nullable<NodeMaterialSystemValues>;
  54108. /**
  54109. * Gets the current class name
  54110. * @returns the class name
  54111. */
  54112. getClassName(): string;
  54113. /**
  54114. * Animate the input if animationType !== None
  54115. * @param scene defines the rendering scene
  54116. */
  54117. animate(scene: Scene): void;
  54118. private _emitDefine;
  54119. initialize(state: NodeMaterialBuildState): void;
  54120. /**
  54121. * Set the input block to its default value (based on its type)
  54122. */
  54123. setDefaultValue(): void;
  54124. private _emitConstant;
  54125. private _emit;
  54126. /** @hidden */
  54127. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54128. /** @hidden */
  54129. _transmit(effect: Effect, scene: Scene): void;
  54130. protected _buildBlock(state: NodeMaterialBuildState): void;
  54131. protected _dumpPropertiesCode(): string;
  54132. serialize(): any;
  54133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54134. }
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * Defines a connection point for a block
  54139. */
  54140. export class NodeMaterialConnectionPoint {
  54141. /** @hidden */
  54142. _ownerBlock: NodeMaterialBlock;
  54143. /** @hidden */
  54144. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54145. private _endpoints;
  54146. private _associatedVariableName;
  54147. /** @hidden */
  54148. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54149. /** @hidden */
  54150. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54151. private _type;
  54152. /** @hidden */
  54153. _enforceAssociatedVariableName: boolean;
  54154. /**
  54155. * Gets or sets the additional types supported by this connection point
  54156. */
  54157. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54158. /**
  54159. * Gets or sets the additional types excluded by this connection point
  54160. */
  54161. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54162. /**
  54163. * Observable triggered when this point is connected
  54164. */
  54165. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54166. /**
  54167. * Gets or sets the associated variable name in the shader
  54168. */
  54169. associatedVariableName: string;
  54170. /**
  54171. * Gets or sets the connection point type (default is float)
  54172. */
  54173. type: NodeMaterialBlockConnectionPointTypes;
  54174. /**
  54175. * Gets or sets the connection point name
  54176. */
  54177. name: string;
  54178. /**
  54179. * Gets or sets a boolean indicating that this connection point can be omitted
  54180. */
  54181. isOptional: boolean;
  54182. /**
  54183. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54184. */
  54185. define: string;
  54186. /** @hidden */
  54187. _prioritizeVertex: boolean;
  54188. private _target;
  54189. /** Gets or sets the target of that connection point */
  54190. target: NodeMaterialBlockTargets;
  54191. /**
  54192. * Gets a boolean indicating that the current point is connected
  54193. */
  54194. readonly isConnected: boolean;
  54195. /**
  54196. * Gets a boolean indicating that the current point is connected to an input block
  54197. */
  54198. readonly isConnectedToInputBlock: boolean;
  54199. /**
  54200. * Gets a the connected input block (if any)
  54201. */
  54202. readonly connectInputBlock: Nullable<InputBlock>;
  54203. /** Get the other side of the connection (if any) */
  54204. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54205. /** Get the block that owns this connection point */
  54206. readonly ownerBlock: NodeMaterialBlock;
  54207. /** Get the block connected on the other side of this connection (if any) */
  54208. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54209. /** Get the block connected on the endpoints of this connection (if any) */
  54210. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54211. /** Gets the list of connected endpoints */
  54212. readonly endpoints: NodeMaterialConnectionPoint[];
  54213. /** Gets a boolean indicating if that output point is connected to at least one input */
  54214. readonly hasEndpoints: boolean;
  54215. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54216. readonly isConnectedInVertexShader: boolean;
  54217. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54218. readonly isConnectedInFragmentShader: boolean;
  54219. /**
  54220. * Creates a new connection point
  54221. * @param name defines the connection point name
  54222. * @param ownerBlock defines the block hosting this connection point
  54223. */
  54224. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54225. /**
  54226. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54227. * @returns the class name
  54228. */
  54229. getClassName(): string;
  54230. /**
  54231. * Gets an boolean indicating if the current point can be connected to another point
  54232. * @param connectionPoint defines the other connection point
  54233. * @returns true if the connection is possible
  54234. */
  54235. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54236. /**
  54237. * Connect this point to another connection point
  54238. * @param connectionPoint defines the other connection point
  54239. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54240. * @returns the current connection point
  54241. */
  54242. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54243. /**
  54244. * Disconnect this point from one of his endpoint
  54245. * @param endpoint defines the other connection point
  54246. * @returns the current connection point
  54247. */
  54248. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54249. /**
  54250. * Serializes this point in a JSON representation
  54251. * @returns the serialized point object
  54252. */
  54253. serialize(): any;
  54254. /**
  54255. * Release resources
  54256. */
  54257. dispose(): void;
  54258. }
  54259. }
  54260. declare module BABYLON {
  54261. /**
  54262. * Block used to add support for vertex skinning (bones)
  54263. */
  54264. export class BonesBlock extends NodeMaterialBlock {
  54265. /**
  54266. * Creates a new BonesBlock
  54267. * @param name defines the block name
  54268. */
  54269. constructor(name: string);
  54270. /**
  54271. * Initialize the block and prepare the context for build
  54272. * @param state defines the state that will be used for the build
  54273. */
  54274. initialize(state: NodeMaterialBuildState): void;
  54275. /**
  54276. * Gets the current class name
  54277. * @returns the class name
  54278. */
  54279. getClassName(): string;
  54280. /**
  54281. * Gets the matrix indices input component
  54282. */
  54283. readonly matricesIndices: NodeMaterialConnectionPoint;
  54284. /**
  54285. * Gets the matrix weights input component
  54286. */
  54287. readonly matricesWeights: NodeMaterialConnectionPoint;
  54288. /**
  54289. * Gets the extra matrix indices input component
  54290. */
  54291. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54292. /**
  54293. * Gets the extra matrix weights input component
  54294. */
  54295. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54296. /**
  54297. * Gets the world input component
  54298. */
  54299. readonly world: NodeMaterialConnectionPoint;
  54300. /**
  54301. * Gets the output component
  54302. */
  54303. readonly output: NodeMaterialConnectionPoint;
  54304. autoConfigure(material: NodeMaterial): void;
  54305. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54308. protected _buildBlock(state: NodeMaterialBuildState): this;
  54309. }
  54310. }
  54311. declare module BABYLON {
  54312. /**
  54313. * Block used to add support for instances
  54314. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54315. */
  54316. export class InstancesBlock extends NodeMaterialBlock {
  54317. /**
  54318. * Creates a new InstancesBlock
  54319. * @param name defines the block name
  54320. */
  54321. constructor(name: string);
  54322. /**
  54323. * Gets the current class name
  54324. * @returns the class name
  54325. */
  54326. getClassName(): string;
  54327. /**
  54328. * Gets the first world row input component
  54329. */
  54330. readonly world0: NodeMaterialConnectionPoint;
  54331. /**
  54332. * Gets the second world row input component
  54333. */
  54334. readonly world1: NodeMaterialConnectionPoint;
  54335. /**
  54336. * Gets the third world row input component
  54337. */
  54338. readonly world2: NodeMaterialConnectionPoint;
  54339. /**
  54340. * Gets the forth world row input component
  54341. */
  54342. readonly world3: NodeMaterialConnectionPoint;
  54343. /**
  54344. * Gets the world input component
  54345. */
  54346. readonly world: NodeMaterialConnectionPoint;
  54347. /**
  54348. * Gets the output component
  54349. */
  54350. readonly output: NodeMaterialConnectionPoint;
  54351. autoConfigure(material: NodeMaterial): void;
  54352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54353. protected _buildBlock(state: NodeMaterialBuildState): this;
  54354. }
  54355. }
  54356. declare module BABYLON {
  54357. /**
  54358. * Block used to add morph targets support to vertex shader
  54359. */
  54360. export class MorphTargetsBlock extends NodeMaterialBlock {
  54361. private _repeatableContentAnchor;
  54362. private _repeatebleContentGenerated;
  54363. /**
  54364. * Create a new MorphTargetsBlock
  54365. * @param name defines the block name
  54366. */
  54367. constructor(name: string);
  54368. /**
  54369. * Gets the current class name
  54370. * @returns the class name
  54371. */
  54372. getClassName(): string;
  54373. /**
  54374. * Gets the position input component
  54375. */
  54376. readonly position: NodeMaterialConnectionPoint;
  54377. /**
  54378. * Gets the normal input component
  54379. */
  54380. readonly normal: NodeMaterialConnectionPoint;
  54381. /**
  54382. * Gets the tangent input component
  54383. */
  54384. readonly tangent: NodeMaterialConnectionPoint;
  54385. /**
  54386. * Gets the tangent input component
  54387. */
  54388. readonly uv: NodeMaterialConnectionPoint;
  54389. /**
  54390. * Gets the position output component
  54391. */
  54392. readonly positionOutput: NodeMaterialConnectionPoint;
  54393. /**
  54394. * Gets the normal output component
  54395. */
  54396. readonly normalOutput: NodeMaterialConnectionPoint;
  54397. /**
  54398. * Gets the tangent output component
  54399. */
  54400. readonly tangentOutput: NodeMaterialConnectionPoint;
  54401. /**
  54402. * Gets the tangent output component
  54403. */
  54404. readonly uvOutput: NodeMaterialConnectionPoint;
  54405. initialize(state: NodeMaterialBuildState): void;
  54406. autoConfigure(material: NodeMaterial): void;
  54407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54409. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54410. protected _buildBlock(state: NodeMaterialBuildState): this;
  54411. }
  54412. }
  54413. declare module BABYLON {
  54414. /**
  54415. * Block used to get data information from a light
  54416. */
  54417. export class LightInformationBlock extends NodeMaterialBlock {
  54418. private _lightDataUniformName;
  54419. private _lightColorUniformName;
  54420. private _lightTypeDefineName;
  54421. /**
  54422. * Gets or sets the light associated with this block
  54423. */
  54424. light: Nullable<Light>;
  54425. /**
  54426. * Creates a new LightInformationBlock
  54427. * @param name defines the block name
  54428. */
  54429. constructor(name: string);
  54430. /**
  54431. * Gets the current class name
  54432. * @returns the class name
  54433. */
  54434. getClassName(): string;
  54435. /**
  54436. * Gets the world position input component
  54437. */
  54438. readonly worldPosition: NodeMaterialConnectionPoint;
  54439. /**
  54440. * Gets the direction output component
  54441. */
  54442. readonly direction: NodeMaterialConnectionPoint;
  54443. /**
  54444. * Gets the direction output component
  54445. */
  54446. readonly color: NodeMaterialConnectionPoint;
  54447. /**
  54448. * Gets the direction output component
  54449. */
  54450. readonly intensity: NodeMaterialConnectionPoint;
  54451. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54453. protected _buildBlock(state: NodeMaterialBuildState): this;
  54454. serialize(): any;
  54455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * Block used to add image processing support to fragment shader
  54461. */
  54462. export class ImageProcessingBlock extends NodeMaterialBlock {
  54463. /**
  54464. * Create a new ImageProcessingBlock
  54465. * @param name defines the block name
  54466. */
  54467. constructor(name: string);
  54468. /**
  54469. * Gets the current class name
  54470. * @returns the class name
  54471. */
  54472. getClassName(): string;
  54473. /**
  54474. * Gets the color input component
  54475. */
  54476. readonly color: NodeMaterialConnectionPoint;
  54477. /**
  54478. * Gets the output component
  54479. */
  54480. readonly output: NodeMaterialConnectionPoint;
  54481. /**
  54482. * Initialize the block and prepare the context for build
  54483. * @param state defines the state that will be used for the build
  54484. */
  54485. initialize(state: NodeMaterialBuildState): void;
  54486. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54489. protected _buildBlock(state: NodeMaterialBuildState): this;
  54490. }
  54491. }
  54492. declare module BABYLON {
  54493. /**
  54494. * Block used to pertub normals based on a normal map
  54495. */
  54496. export class PerturbNormalBlock extends NodeMaterialBlock {
  54497. private _tangentSpaceParameterName;
  54498. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54499. invertX: boolean;
  54500. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54501. invertY: boolean;
  54502. /**
  54503. * Create a new PerturbNormalBlock
  54504. * @param name defines the block name
  54505. */
  54506. constructor(name: string);
  54507. /**
  54508. * Gets the current class name
  54509. * @returns the class name
  54510. */
  54511. getClassName(): string;
  54512. /**
  54513. * Gets the world position input component
  54514. */
  54515. readonly worldPosition: NodeMaterialConnectionPoint;
  54516. /**
  54517. * Gets the world normal input component
  54518. */
  54519. readonly worldNormal: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the uv input component
  54522. */
  54523. readonly uv: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the normal map color input component
  54526. */
  54527. readonly normalMapColor: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the strength input component
  54530. */
  54531. readonly strength: NodeMaterialConnectionPoint;
  54532. /**
  54533. * Gets the output component
  54534. */
  54535. readonly output: NodeMaterialConnectionPoint;
  54536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54538. autoConfigure(material: NodeMaterial): void;
  54539. protected _buildBlock(state: NodeMaterialBuildState): this;
  54540. protected _dumpPropertiesCode(): string;
  54541. serialize(): any;
  54542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54543. }
  54544. }
  54545. declare module BABYLON {
  54546. /**
  54547. * Block used to discard a pixel if a value is smaller than a cutoff
  54548. */
  54549. export class DiscardBlock extends NodeMaterialBlock {
  54550. /**
  54551. * Create a new DiscardBlock
  54552. * @param name defines the block name
  54553. */
  54554. constructor(name: string);
  54555. /**
  54556. * Gets the current class name
  54557. * @returns the class name
  54558. */
  54559. getClassName(): string;
  54560. /**
  54561. * Gets the color input component
  54562. */
  54563. readonly value: NodeMaterialConnectionPoint;
  54564. /**
  54565. * Gets the cutoff input component
  54566. */
  54567. readonly cutoff: NodeMaterialConnectionPoint;
  54568. protected _buildBlock(state: NodeMaterialBuildState): this;
  54569. }
  54570. }
  54571. declare module BABYLON {
  54572. /**
  54573. * Block used to add support for scene fog
  54574. */
  54575. export class FogBlock extends NodeMaterialBlock {
  54576. private _fogDistanceName;
  54577. private _fogParameters;
  54578. /**
  54579. * Create a new FogBlock
  54580. * @param name defines the block name
  54581. */
  54582. constructor(name: string);
  54583. /**
  54584. * Gets the current class name
  54585. * @returns the class name
  54586. */
  54587. getClassName(): string;
  54588. /**
  54589. * Gets the world position input component
  54590. */
  54591. readonly worldPosition: NodeMaterialConnectionPoint;
  54592. /**
  54593. * Gets the view input component
  54594. */
  54595. readonly view: NodeMaterialConnectionPoint;
  54596. /**
  54597. * Gets the color input component
  54598. */
  54599. readonly input: NodeMaterialConnectionPoint;
  54600. /**
  54601. * Gets the fog color input component
  54602. */
  54603. readonly fogColor: NodeMaterialConnectionPoint;
  54604. /**
  54605. * Gets the output component
  54606. */
  54607. readonly output: NodeMaterialConnectionPoint;
  54608. autoConfigure(material: NodeMaterial): void;
  54609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54611. protected _buildBlock(state: NodeMaterialBuildState): this;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /**
  54616. * Block used to add light in the fragment shader
  54617. */
  54618. export class LightBlock extends NodeMaterialBlock {
  54619. private _lightId;
  54620. /**
  54621. * Gets or sets the light associated with this block
  54622. */
  54623. light: Nullable<Light>;
  54624. /**
  54625. * Create a new LightBlock
  54626. * @param name defines the block name
  54627. */
  54628. constructor(name: string);
  54629. /**
  54630. * Gets the current class name
  54631. * @returns the class name
  54632. */
  54633. getClassName(): string;
  54634. /**
  54635. * Gets the world position input component
  54636. */
  54637. readonly worldPosition: NodeMaterialConnectionPoint;
  54638. /**
  54639. * Gets the world normal input component
  54640. */
  54641. readonly worldNormal: NodeMaterialConnectionPoint;
  54642. /**
  54643. * Gets the camera (or eye) position component
  54644. */
  54645. readonly cameraPosition: NodeMaterialConnectionPoint;
  54646. /**
  54647. * Gets the glossiness component
  54648. */
  54649. readonly glossiness: NodeMaterialConnectionPoint;
  54650. /**
  54651. * Gets the glossinness power component
  54652. */
  54653. readonly glossPower: NodeMaterialConnectionPoint;
  54654. /**
  54655. * Gets the diffuse color component
  54656. */
  54657. readonly diffuseColor: NodeMaterialConnectionPoint;
  54658. /**
  54659. * Gets the specular color component
  54660. */
  54661. readonly specularColor: NodeMaterialConnectionPoint;
  54662. /**
  54663. * Gets the diffuse output component
  54664. */
  54665. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the specular output component
  54668. */
  54669. readonly specularOutput: NodeMaterialConnectionPoint;
  54670. autoConfigure(material: NodeMaterial): void;
  54671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54672. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54674. private _injectVertexCode;
  54675. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54676. serialize(): any;
  54677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54678. }
  54679. }
  54680. declare module BABYLON {
  54681. /**
  54682. * Block used to multiply 2 values
  54683. */
  54684. export class MultiplyBlock extends NodeMaterialBlock {
  54685. /**
  54686. * Creates a new MultiplyBlock
  54687. * @param name defines the block name
  54688. */
  54689. constructor(name: string);
  54690. /**
  54691. * Gets the current class name
  54692. * @returns the class name
  54693. */
  54694. getClassName(): string;
  54695. /**
  54696. * Gets the left operand input component
  54697. */
  54698. readonly left: NodeMaterialConnectionPoint;
  54699. /**
  54700. * Gets the right operand input component
  54701. */
  54702. readonly right: NodeMaterialConnectionPoint;
  54703. /**
  54704. * Gets the output component
  54705. */
  54706. readonly output: NodeMaterialConnectionPoint;
  54707. protected _buildBlock(state: NodeMaterialBuildState): this;
  54708. }
  54709. }
  54710. declare module BABYLON {
  54711. /**
  54712. * Block used to add 2 vectors
  54713. */
  54714. export class AddBlock extends NodeMaterialBlock {
  54715. /**
  54716. * Creates a new AddBlock
  54717. * @param name defines the block name
  54718. */
  54719. constructor(name: string);
  54720. /**
  54721. * Gets the current class name
  54722. * @returns the class name
  54723. */
  54724. getClassName(): string;
  54725. /**
  54726. * Gets the left operand input component
  54727. */
  54728. readonly left: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the right operand input component
  54731. */
  54732. readonly right: NodeMaterialConnectionPoint;
  54733. /**
  54734. * Gets the output component
  54735. */
  54736. readonly output: NodeMaterialConnectionPoint;
  54737. protected _buildBlock(state: NodeMaterialBuildState): this;
  54738. }
  54739. }
  54740. declare module BABYLON {
  54741. /**
  54742. * Block used to scale a vector by a float
  54743. */
  54744. export class ScaleBlock extends NodeMaterialBlock {
  54745. /**
  54746. * Creates a new ScaleBlock
  54747. * @param name defines the block name
  54748. */
  54749. constructor(name: string);
  54750. /**
  54751. * Gets the current class name
  54752. * @returns the class name
  54753. */
  54754. getClassName(): string;
  54755. /**
  54756. * Gets the input component
  54757. */
  54758. readonly input: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the factor input component
  54761. */
  54762. readonly factor: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the output component
  54765. */
  54766. readonly output: NodeMaterialConnectionPoint;
  54767. protected _buildBlock(state: NodeMaterialBuildState): this;
  54768. }
  54769. }
  54770. declare module BABYLON {
  54771. /**
  54772. * Block used to clamp a float
  54773. */
  54774. export class ClampBlock extends NodeMaterialBlock {
  54775. /** Gets or sets the minimum range */
  54776. minimum: number;
  54777. /** Gets or sets the maximum range */
  54778. maximum: number;
  54779. /**
  54780. * Creates a new ClampBlock
  54781. * @param name defines the block name
  54782. */
  54783. constructor(name: string);
  54784. /**
  54785. * Gets the current class name
  54786. * @returns the class name
  54787. */
  54788. getClassName(): string;
  54789. /**
  54790. * Gets the value input component
  54791. */
  54792. readonly value: NodeMaterialConnectionPoint;
  54793. /**
  54794. * Gets the output component
  54795. */
  54796. readonly output: NodeMaterialConnectionPoint;
  54797. protected _buildBlock(state: NodeMaterialBuildState): this;
  54798. protected _dumpPropertiesCode(): string;
  54799. serialize(): any;
  54800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54801. }
  54802. }
  54803. declare module BABYLON {
  54804. /**
  54805. * Block used to apply a cross product between 2 vectors
  54806. */
  54807. export class CrossBlock extends NodeMaterialBlock {
  54808. /**
  54809. * Creates a new CrossBlock
  54810. * @param name defines the block name
  54811. */
  54812. constructor(name: string);
  54813. /**
  54814. * Gets the current class name
  54815. * @returns the class name
  54816. */
  54817. getClassName(): string;
  54818. /**
  54819. * Gets the left operand input component
  54820. */
  54821. readonly left: NodeMaterialConnectionPoint;
  54822. /**
  54823. * Gets the right operand input component
  54824. */
  54825. readonly right: NodeMaterialConnectionPoint;
  54826. /**
  54827. * Gets the output component
  54828. */
  54829. readonly output: NodeMaterialConnectionPoint;
  54830. protected _buildBlock(state: NodeMaterialBuildState): this;
  54831. }
  54832. }
  54833. declare module BABYLON {
  54834. /**
  54835. * Block used to apply a dot product between 2 vectors
  54836. */
  54837. export class DotBlock extends NodeMaterialBlock {
  54838. /**
  54839. * Creates a new DotBlock
  54840. * @param name defines the block name
  54841. */
  54842. constructor(name: string);
  54843. /**
  54844. * Gets the current class name
  54845. * @returns the class name
  54846. */
  54847. getClassName(): string;
  54848. /**
  54849. * Gets the left operand input component
  54850. */
  54851. readonly left: NodeMaterialConnectionPoint;
  54852. /**
  54853. * Gets the right operand input component
  54854. */
  54855. readonly right: NodeMaterialConnectionPoint;
  54856. /**
  54857. * Gets the output component
  54858. */
  54859. readonly output: NodeMaterialConnectionPoint;
  54860. protected _buildBlock(state: NodeMaterialBuildState): this;
  54861. }
  54862. }
  54863. declare module BABYLON {
  54864. /**
  54865. * Block used to remap a float from a range to a new one
  54866. */
  54867. export class RemapBlock extends NodeMaterialBlock {
  54868. /**
  54869. * Gets or sets the source range
  54870. */
  54871. sourceRange: Vector2;
  54872. /**
  54873. * Gets or sets the target range
  54874. */
  54875. targetRange: Vector2;
  54876. /**
  54877. * Creates a new RemapBlock
  54878. * @param name defines the block name
  54879. */
  54880. constructor(name: string);
  54881. /**
  54882. * Gets the current class name
  54883. * @returns the class name
  54884. */
  54885. getClassName(): string;
  54886. /**
  54887. * Gets the input component
  54888. */
  54889. readonly input: NodeMaterialConnectionPoint;
  54890. /**
  54891. * Gets the source min input component
  54892. */
  54893. readonly sourceMin: NodeMaterialConnectionPoint;
  54894. /**
  54895. * Gets the source max input component
  54896. */
  54897. readonly sourceMax: NodeMaterialConnectionPoint;
  54898. /**
  54899. * Gets the target min input component
  54900. */
  54901. readonly targetMin: NodeMaterialConnectionPoint;
  54902. /**
  54903. * Gets the target max input component
  54904. */
  54905. readonly targetMax: NodeMaterialConnectionPoint;
  54906. /**
  54907. * Gets the output component
  54908. */
  54909. readonly output: NodeMaterialConnectionPoint;
  54910. protected _buildBlock(state: NodeMaterialBuildState): this;
  54911. protected _dumpPropertiesCode(): string;
  54912. serialize(): any;
  54913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54914. }
  54915. }
  54916. declare module BABYLON {
  54917. /**
  54918. * Block used to normalize a vector
  54919. */
  54920. export class NormalizeBlock extends NodeMaterialBlock {
  54921. /**
  54922. * Creates a new NormalizeBlock
  54923. * @param name defines the block name
  54924. */
  54925. constructor(name: string);
  54926. /**
  54927. * Gets the current class name
  54928. * @returns the class name
  54929. */
  54930. getClassName(): string;
  54931. /**
  54932. * Gets the input component
  54933. */
  54934. readonly input: NodeMaterialConnectionPoint;
  54935. /**
  54936. * Gets the output component
  54937. */
  54938. readonly output: NodeMaterialConnectionPoint;
  54939. protected _buildBlock(state: NodeMaterialBuildState): this;
  54940. }
  54941. }
  54942. declare module BABYLON {
  54943. /**
  54944. * Operations supported by the Trigonometry block
  54945. */
  54946. export enum TrigonometryBlockOperations {
  54947. /** Cos */
  54948. Cos = 0,
  54949. /** Sin */
  54950. Sin = 1,
  54951. /** Abs */
  54952. Abs = 2,
  54953. /** Exp */
  54954. Exp = 3,
  54955. /** Exp2 */
  54956. Exp2 = 4,
  54957. /** Round */
  54958. Round = 5,
  54959. /** Floor */
  54960. Floor = 6,
  54961. /** Ceiling */
  54962. Ceiling = 7,
  54963. /** Square root */
  54964. Sqrt = 8,
  54965. /** Log */
  54966. Log = 9,
  54967. /** Tangent */
  54968. Tan = 10,
  54969. /** Arc tangent */
  54970. ArcTan = 11,
  54971. /** Arc cosinus */
  54972. ArcCos = 12,
  54973. /** Arc sinus */
  54974. ArcSin = 13,
  54975. /** Fraction */
  54976. Fract = 14,
  54977. /** Sign */
  54978. Sign = 15,
  54979. /** To radians (from degrees) */
  54980. Radians = 16,
  54981. /** To degrees (from radians) */
  54982. Degrees = 17
  54983. }
  54984. /**
  54985. * Block used to apply trigonometry operation to floats
  54986. */
  54987. export class TrigonometryBlock extends NodeMaterialBlock {
  54988. /**
  54989. * Gets or sets the operation applied by the block
  54990. */
  54991. operation: TrigonometryBlockOperations;
  54992. /**
  54993. * Creates a new TrigonometryBlock
  54994. * @param name defines the block name
  54995. */
  54996. constructor(name: string);
  54997. /**
  54998. * Gets the current class name
  54999. * @returns the class name
  55000. */
  55001. getClassName(): string;
  55002. /**
  55003. * Gets the input component
  55004. */
  55005. readonly input: NodeMaterialConnectionPoint;
  55006. /**
  55007. * Gets the output component
  55008. */
  55009. readonly output: NodeMaterialConnectionPoint;
  55010. protected _buildBlock(state: NodeMaterialBuildState): this;
  55011. serialize(): any;
  55012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55013. }
  55014. }
  55015. declare module BABYLON {
  55016. /**
  55017. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55018. */
  55019. export class ColorMergerBlock extends NodeMaterialBlock {
  55020. /**
  55021. * Create a new ColorMergerBlock
  55022. * @param name defines the block name
  55023. */
  55024. constructor(name: string);
  55025. /**
  55026. * Gets the current class name
  55027. * @returns the class name
  55028. */
  55029. getClassName(): string;
  55030. /**
  55031. * Gets the r component (input)
  55032. */
  55033. readonly r: NodeMaterialConnectionPoint;
  55034. /**
  55035. * Gets the g component (input)
  55036. */
  55037. readonly g: NodeMaterialConnectionPoint;
  55038. /**
  55039. * Gets the b component (input)
  55040. */
  55041. readonly b: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the a component (input)
  55044. */
  55045. readonly a: NodeMaterialConnectionPoint;
  55046. /**
  55047. * Gets the rgba component (output)
  55048. */
  55049. readonly rgba: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the rgb component (output)
  55052. */
  55053. readonly rgb: NodeMaterialConnectionPoint;
  55054. protected _buildBlock(state: NodeMaterialBuildState): this;
  55055. }
  55056. }
  55057. declare module BABYLON {
  55058. /**
  55059. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55060. */
  55061. export class VectorMergerBlock extends NodeMaterialBlock {
  55062. /**
  55063. * Create a new VectorMergerBlock
  55064. * @param name defines the block name
  55065. */
  55066. constructor(name: string);
  55067. /**
  55068. * Gets the current class name
  55069. * @returns the class name
  55070. */
  55071. getClassName(): string;
  55072. /**
  55073. * Gets the x component (input)
  55074. */
  55075. readonly x: NodeMaterialConnectionPoint;
  55076. /**
  55077. * Gets the y component (input)
  55078. */
  55079. readonly y: NodeMaterialConnectionPoint;
  55080. /**
  55081. * Gets the z component (input)
  55082. */
  55083. readonly z: NodeMaterialConnectionPoint;
  55084. /**
  55085. * Gets the w component (input)
  55086. */
  55087. readonly w: NodeMaterialConnectionPoint;
  55088. /**
  55089. * Gets the xyzw component (output)
  55090. */
  55091. readonly xyzw: NodeMaterialConnectionPoint;
  55092. /**
  55093. * Gets the xyz component (output)
  55094. */
  55095. readonly xyz: NodeMaterialConnectionPoint;
  55096. /**
  55097. * Gets the xy component (output)
  55098. */
  55099. readonly xy: NodeMaterialConnectionPoint;
  55100. protected _buildBlock(state: NodeMaterialBuildState): this;
  55101. }
  55102. }
  55103. declare module BABYLON {
  55104. /**
  55105. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55106. */
  55107. export class ColorSplitterBlock extends NodeMaterialBlock {
  55108. /**
  55109. * Create a new ColorSplitterBlock
  55110. * @param name defines the block name
  55111. */
  55112. constructor(name: string);
  55113. /**
  55114. * Gets the current class name
  55115. * @returns the class name
  55116. */
  55117. getClassName(): string;
  55118. /**
  55119. * Gets the rgba component (input)
  55120. */
  55121. readonly rgba: NodeMaterialConnectionPoint;
  55122. /**
  55123. * Gets the rgb component (input)
  55124. */
  55125. readonly rgbIn: NodeMaterialConnectionPoint;
  55126. /**
  55127. * Gets the rgb component (output)
  55128. */
  55129. readonly rgbOut: NodeMaterialConnectionPoint;
  55130. /**
  55131. * Gets the r component (output)
  55132. */
  55133. readonly r: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the g component (output)
  55136. */
  55137. readonly g: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the b component (output)
  55140. */
  55141. readonly b: NodeMaterialConnectionPoint;
  55142. /**
  55143. * Gets the a component (output)
  55144. */
  55145. readonly a: NodeMaterialConnectionPoint;
  55146. protected _inputRename(name: string): string;
  55147. protected _outputRename(name: string): string;
  55148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55149. }
  55150. }
  55151. declare module BABYLON {
  55152. /**
  55153. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55154. */
  55155. export class VectorSplitterBlock extends NodeMaterialBlock {
  55156. /**
  55157. * Create a new VectorSplitterBlock
  55158. * @param name defines the block name
  55159. */
  55160. constructor(name: string);
  55161. /**
  55162. * Gets the current class name
  55163. * @returns the class name
  55164. */
  55165. getClassName(): string;
  55166. /**
  55167. * Gets the xyzw component (input)
  55168. */
  55169. readonly xyzw: NodeMaterialConnectionPoint;
  55170. /**
  55171. * Gets the xyz component (input)
  55172. */
  55173. readonly xyzIn: NodeMaterialConnectionPoint;
  55174. /**
  55175. * Gets the xy component (input)
  55176. */
  55177. readonly xyIn: NodeMaterialConnectionPoint;
  55178. /**
  55179. * Gets the xyz component (output)
  55180. */
  55181. readonly xyzOut: NodeMaterialConnectionPoint;
  55182. /**
  55183. * Gets the xy component (output)
  55184. */
  55185. readonly xyOut: NodeMaterialConnectionPoint;
  55186. /**
  55187. * Gets the x component (output)
  55188. */
  55189. readonly x: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the y component (output)
  55192. */
  55193. readonly y: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the z component (output)
  55196. */
  55197. readonly z: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the w component (output)
  55200. */
  55201. readonly w: NodeMaterialConnectionPoint;
  55202. protected _inputRename(name: string): string;
  55203. protected _outputRename(name: string): string;
  55204. protected _buildBlock(state: NodeMaterialBuildState): this;
  55205. }
  55206. }
  55207. declare module BABYLON {
  55208. /**
  55209. * Block used to lerp between 2 values
  55210. */
  55211. export class LerpBlock extends NodeMaterialBlock {
  55212. /**
  55213. * Creates a new LerpBlock
  55214. * @param name defines the block name
  55215. */
  55216. constructor(name: string);
  55217. /**
  55218. * Gets the current class name
  55219. * @returns the class name
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Gets the left operand input component
  55224. */
  55225. readonly left: NodeMaterialConnectionPoint;
  55226. /**
  55227. * Gets the right operand input component
  55228. */
  55229. readonly right: NodeMaterialConnectionPoint;
  55230. /**
  55231. * Gets the gradient operand input component
  55232. */
  55233. readonly gradient: NodeMaterialConnectionPoint;
  55234. /**
  55235. * Gets the output component
  55236. */
  55237. readonly output: NodeMaterialConnectionPoint;
  55238. protected _buildBlock(state: NodeMaterialBuildState): this;
  55239. }
  55240. }
  55241. declare module BABYLON {
  55242. /**
  55243. * Block used to divide 2 vectors
  55244. */
  55245. export class DivideBlock extends NodeMaterialBlock {
  55246. /**
  55247. * Creates a new DivideBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the left operand input component
  55258. */
  55259. readonly left: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the right operand input component
  55262. */
  55263. readonly right: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the output component
  55266. */
  55267. readonly output: NodeMaterialConnectionPoint;
  55268. protected _buildBlock(state: NodeMaterialBuildState): this;
  55269. }
  55270. }
  55271. declare module BABYLON {
  55272. /**
  55273. * Block used to subtract 2 vectors
  55274. */
  55275. export class SubtractBlock extends NodeMaterialBlock {
  55276. /**
  55277. * Creates a new SubtractBlock
  55278. * @param name defines the block name
  55279. */
  55280. constructor(name: string);
  55281. /**
  55282. * Gets the current class name
  55283. * @returns the class name
  55284. */
  55285. getClassName(): string;
  55286. /**
  55287. * Gets the left operand input component
  55288. */
  55289. readonly left: NodeMaterialConnectionPoint;
  55290. /**
  55291. * Gets the right operand input component
  55292. */
  55293. readonly right: NodeMaterialConnectionPoint;
  55294. /**
  55295. * Gets the output component
  55296. */
  55297. readonly output: NodeMaterialConnectionPoint;
  55298. protected _buildBlock(state: NodeMaterialBuildState): this;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /**
  55303. * Block used to step a value
  55304. */
  55305. export class StepBlock extends NodeMaterialBlock {
  55306. /**
  55307. * Creates a new StepBlock
  55308. * @param name defines the block name
  55309. */
  55310. constructor(name: string);
  55311. /**
  55312. * Gets the current class name
  55313. * @returns the class name
  55314. */
  55315. getClassName(): string;
  55316. /**
  55317. * Gets the value operand input component
  55318. */
  55319. readonly value: NodeMaterialConnectionPoint;
  55320. /**
  55321. * Gets the edge operand input component
  55322. */
  55323. readonly edge: NodeMaterialConnectionPoint;
  55324. /**
  55325. * Gets the output component
  55326. */
  55327. readonly output: NodeMaterialConnectionPoint;
  55328. protected _buildBlock(state: NodeMaterialBuildState): this;
  55329. }
  55330. }
  55331. declare module BABYLON {
  55332. /**
  55333. * Block used to get the opposite (1 - x) of a value
  55334. */
  55335. export class OneMinusBlock extends NodeMaterialBlock {
  55336. /**
  55337. * Creates a new OneMinusBlock
  55338. * @param name defines the block name
  55339. */
  55340. constructor(name: string);
  55341. /**
  55342. * Gets the current class name
  55343. * @returns the class name
  55344. */
  55345. getClassName(): string;
  55346. /**
  55347. * Gets the input component
  55348. */
  55349. readonly input: NodeMaterialConnectionPoint;
  55350. /**
  55351. * Gets the output component
  55352. */
  55353. readonly output: NodeMaterialConnectionPoint;
  55354. protected _buildBlock(state: NodeMaterialBuildState): this;
  55355. }
  55356. }
  55357. declare module BABYLON {
  55358. /**
  55359. * Block used to get the view direction
  55360. */
  55361. export class ViewDirectionBlock extends NodeMaterialBlock {
  55362. /**
  55363. * Creates a new ViewDirectionBlock
  55364. * @param name defines the block name
  55365. */
  55366. constructor(name: string);
  55367. /**
  55368. * Gets the current class name
  55369. * @returns the class name
  55370. */
  55371. getClassName(): string;
  55372. /**
  55373. * Gets the world position component
  55374. */
  55375. readonly worldPosition: NodeMaterialConnectionPoint;
  55376. /**
  55377. * Gets the camera position component
  55378. */
  55379. readonly cameraPosition: NodeMaterialConnectionPoint;
  55380. /**
  55381. * Gets the output component
  55382. */
  55383. readonly output: NodeMaterialConnectionPoint;
  55384. autoConfigure(material: NodeMaterial): void;
  55385. protected _buildBlock(state: NodeMaterialBuildState): this;
  55386. }
  55387. }
  55388. declare module BABYLON {
  55389. /**
  55390. * Block used to compute fresnel value
  55391. */
  55392. export class FresnelBlock extends NodeMaterialBlock {
  55393. /**
  55394. * Create a new FresnelBlock
  55395. * @param name defines the block name
  55396. */
  55397. constructor(name: string);
  55398. /**
  55399. * Gets the current class name
  55400. * @returns the class name
  55401. */
  55402. getClassName(): string;
  55403. /**
  55404. * Gets the world normal input component
  55405. */
  55406. readonly worldNormal: NodeMaterialConnectionPoint;
  55407. /**
  55408. * Gets the view direction input component
  55409. */
  55410. readonly viewDirection: NodeMaterialConnectionPoint;
  55411. /**
  55412. * Gets the bias input component
  55413. */
  55414. readonly bias: NodeMaterialConnectionPoint;
  55415. /**
  55416. * Gets the camera (or eye) position component
  55417. */
  55418. readonly power: NodeMaterialConnectionPoint;
  55419. /**
  55420. * Gets the fresnel output component
  55421. */
  55422. readonly fresnel: NodeMaterialConnectionPoint;
  55423. autoConfigure(material: NodeMaterial): void;
  55424. protected _buildBlock(state: NodeMaterialBuildState): this;
  55425. }
  55426. }
  55427. declare module BABYLON {
  55428. /**
  55429. * Block used to get the max of 2 values
  55430. */
  55431. export class MaxBlock extends NodeMaterialBlock {
  55432. /**
  55433. * Creates a new MaxBlock
  55434. * @param name defines the block name
  55435. */
  55436. constructor(name: string);
  55437. /**
  55438. * Gets the current class name
  55439. * @returns the class name
  55440. */
  55441. getClassName(): string;
  55442. /**
  55443. * Gets the left operand input component
  55444. */
  55445. readonly left: NodeMaterialConnectionPoint;
  55446. /**
  55447. * Gets the right operand input component
  55448. */
  55449. readonly right: NodeMaterialConnectionPoint;
  55450. /**
  55451. * Gets the output component
  55452. */
  55453. readonly output: NodeMaterialConnectionPoint;
  55454. protected _buildBlock(state: NodeMaterialBuildState): this;
  55455. }
  55456. }
  55457. declare module BABYLON {
  55458. /**
  55459. * Block used to get the min of 2 values
  55460. */
  55461. export class MinBlock extends NodeMaterialBlock {
  55462. /**
  55463. * Creates a new MinBlock
  55464. * @param name defines the block name
  55465. */
  55466. constructor(name: string);
  55467. /**
  55468. * Gets the current class name
  55469. * @returns the class name
  55470. */
  55471. getClassName(): string;
  55472. /**
  55473. * Gets the left operand input component
  55474. */
  55475. readonly left: NodeMaterialConnectionPoint;
  55476. /**
  55477. * Gets the right operand input component
  55478. */
  55479. readonly right: NodeMaterialConnectionPoint;
  55480. /**
  55481. * Gets the output component
  55482. */
  55483. readonly output: NodeMaterialConnectionPoint;
  55484. protected _buildBlock(state: NodeMaterialBuildState): this;
  55485. }
  55486. }
  55487. declare module BABYLON {
  55488. /**
  55489. * Block used to get the distance between 2 values
  55490. */
  55491. export class DistanceBlock extends NodeMaterialBlock {
  55492. /**
  55493. * Creates a new DistanceBlock
  55494. * @param name defines the block name
  55495. */
  55496. constructor(name: string);
  55497. /**
  55498. * Gets the current class name
  55499. * @returns the class name
  55500. */
  55501. getClassName(): string;
  55502. /**
  55503. * Gets the left operand input component
  55504. */
  55505. readonly left: NodeMaterialConnectionPoint;
  55506. /**
  55507. * Gets the right operand input component
  55508. */
  55509. readonly right: NodeMaterialConnectionPoint;
  55510. /**
  55511. * Gets the output component
  55512. */
  55513. readonly output: NodeMaterialConnectionPoint;
  55514. protected _buildBlock(state: NodeMaterialBuildState): this;
  55515. }
  55516. }
  55517. declare module BABYLON {
  55518. /**
  55519. * Block used to get the length of a vector
  55520. */
  55521. export class LengthBlock extends NodeMaterialBlock {
  55522. /**
  55523. * Creates a new LengthBlock
  55524. * @param name defines the block name
  55525. */
  55526. constructor(name: string);
  55527. /**
  55528. * Gets the current class name
  55529. * @returns the class name
  55530. */
  55531. getClassName(): string;
  55532. /**
  55533. * Gets the value input component
  55534. */
  55535. readonly value: NodeMaterialConnectionPoint;
  55536. /**
  55537. * Gets the output component
  55538. */
  55539. readonly output: NodeMaterialConnectionPoint;
  55540. protected _buildBlock(state: NodeMaterialBuildState): this;
  55541. }
  55542. }
  55543. declare module BABYLON {
  55544. /**
  55545. * Block used to get negative version of a value (i.e. x * -1)
  55546. */
  55547. export class NegateBlock extends NodeMaterialBlock {
  55548. /**
  55549. * Creates a new NegateBlock
  55550. * @param name defines the block name
  55551. */
  55552. constructor(name: string);
  55553. /**
  55554. * Gets the current class name
  55555. * @returns the class name
  55556. */
  55557. getClassName(): string;
  55558. /**
  55559. * Gets the value input component
  55560. */
  55561. readonly value: NodeMaterialConnectionPoint;
  55562. /**
  55563. * Gets the output component
  55564. */
  55565. readonly output: NodeMaterialConnectionPoint;
  55566. protected _buildBlock(state: NodeMaterialBuildState): this;
  55567. }
  55568. }
  55569. declare module BABYLON {
  55570. /**
  55571. * Block used to get the value of the first parameter raised to the power of the second
  55572. */
  55573. export class PowBlock extends NodeMaterialBlock {
  55574. /**
  55575. * Creates a new PowBlock
  55576. * @param name defines the block name
  55577. */
  55578. constructor(name: string);
  55579. /**
  55580. * Gets the current class name
  55581. * @returns the class name
  55582. */
  55583. getClassName(): string;
  55584. /**
  55585. * Gets the value operand input component
  55586. */
  55587. readonly value: NodeMaterialConnectionPoint;
  55588. /**
  55589. * Gets the power operand input component
  55590. */
  55591. readonly power: NodeMaterialConnectionPoint;
  55592. /**
  55593. * Gets the output component
  55594. */
  55595. readonly output: NodeMaterialConnectionPoint;
  55596. protected _buildBlock(state: NodeMaterialBuildState): this;
  55597. }
  55598. }
  55599. declare module BABYLON {
  55600. /**
  55601. * Block used to get a random number
  55602. */
  55603. export class RandomNumberBlock extends NodeMaterialBlock {
  55604. /**
  55605. * Creates a new RandomNumberBlock
  55606. * @param name defines the block name
  55607. */
  55608. constructor(name: string);
  55609. /**
  55610. * Gets the current class name
  55611. * @returns the class name
  55612. */
  55613. getClassName(): string;
  55614. /**
  55615. * Gets the seed input component
  55616. */
  55617. readonly seed: NodeMaterialConnectionPoint;
  55618. /**
  55619. * Gets the output component
  55620. */
  55621. readonly output: NodeMaterialConnectionPoint;
  55622. protected _buildBlock(state: NodeMaterialBuildState): this;
  55623. }
  55624. }
  55625. declare module BABYLON {
  55626. /**
  55627. * Block used to compute arc tangent of 2 values
  55628. */
  55629. export class ArcTan2Block extends NodeMaterialBlock {
  55630. /**
  55631. * Creates a new ArcTan2Block
  55632. * @param name defines the block name
  55633. */
  55634. constructor(name: string);
  55635. /**
  55636. * Gets the current class name
  55637. * @returns the class name
  55638. */
  55639. getClassName(): string;
  55640. /**
  55641. * Gets the x operand input component
  55642. */
  55643. readonly x: NodeMaterialConnectionPoint;
  55644. /**
  55645. * Gets the y operand input component
  55646. */
  55647. readonly y: NodeMaterialConnectionPoint;
  55648. /**
  55649. * Gets the output component
  55650. */
  55651. readonly output: NodeMaterialConnectionPoint;
  55652. protected _buildBlock(state: NodeMaterialBuildState): this;
  55653. }
  55654. }
  55655. declare module BABYLON {
  55656. /**
  55657. * Block used to smooth step a value
  55658. */
  55659. export class SmoothStepBlock extends NodeMaterialBlock {
  55660. /**
  55661. * Creates a new SmoothStepBlock
  55662. * @param name defines the block name
  55663. */
  55664. constructor(name: string);
  55665. /**
  55666. * Gets the current class name
  55667. * @returns the class name
  55668. */
  55669. getClassName(): string;
  55670. /**
  55671. * Gets the value operand input component
  55672. */
  55673. readonly value: NodeMaterialConnectionPoint;
  55674. /**
  55675. * Gets the first edge operand input component
  55676. */
  55677. readonly edge0: NodeMaterialConnectionPoint;
  55678. /**
  55679. * Gets the second edge operand input component
  55680. */
  55681. readonly edge1: NodeMaterialConnectionPoint;
  55682. /**
  55683. * Gets the output component
  55684. */
  55685. readonly output: NodeMaterialConnectionPoint;
  55686. protected _buildBlock(state: NodeMaterialBuildState): this;
  55687. }
  55688. }
  55689. declare module BABYLON {
  55690. /**
  55691. * Block used to get the reciprocal (1 / x) of a value
  55692. */
  55693. export class ReciprocalBlock extends NodeMaterialBlock {
  55694. /**
  55695. * Creates a new ReciprocalBlock
  55696. * @param name defines the block name
  55697. */
  55698. constructor(name: string);
  55699. /**
  55700. * Gets the current class name
  55701. * @returns the class name
  55702. */
  55703. getClassName(): string;
  55704. /**
  55705. * Gets the input component
  55706. */
  55707. readonly input: NodeMaterialConnectionPoint;
  55708. /**
  55709. * Gets the output component
  55710. */
  55711. readonly output: NodeMaterialConnectionPoint;
  55712. protected _buildBlock(state: NodeMaterialBuildState): this;
  55713. }
  55714. }
  55715. declare module BABYLON {
  55716. /**
  55717. * Block used to replace a color by another one
  55718. */
  55719. export class ReplaceColorBlock extends NodeMaterialBlock {
  55720. /**
  55721. * Creates a new ReplaceColorBlock
  55722. * @param name defines the block name
  55723. */
  55724. constructor(name: string);
  55725. /**
  55726. * Gets the current class name
  55727. * @returns the class name
  55728. */
  55729. getClassName(): string;
  55730. /**
  55731. * Gets the value input component
  55732. */
  55733. readonly value: NodeMaterialConnectionPoint;
  55734. /**
  55735. * Gets the reference input component
  55736. */
  55737. readonly reference: NodeMaterialConnectionPoint;
  55738. /**
  55739. * Gets the distance input component
  55740. */
  55741. readonly distance: NodeMaterialConnectionPoint;
  55742. /**
  55743. * Gets the replacement input component
  55744. */
  55745. readonly replacement: NodeMaterialConnectionPoint;
  55746. /**
  55747. * Gets the output component
  55748. */
  55749. readonly output: NodeMaterialConnectionPoint;
  55750. protected _buildBlock(state: NodeMaterialBuildState): this;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. /**
  55755. * Block used to posterize a value
  55756. * @see https://en.wikipedia.org/wiki/Posterization
  55757. */
  55758. export class PosterizeBlock extends NodeMaterialBlock {
  55759. /**
  55760. * Creates a new PosterizeBlock
  55761. * @param name defines the block name
  55762. */
  55763. constructor(name: string);
  55764. /**
  55765. * Gets the current class name
  55766. * @returns the class name
  55767. */
  55768. getClassName(): string;
  55769. /**
  55770. * Gets the value input component
  55771. */
  55772. readonly value: NodeMaterialConnectionPoint;
  55773. /**
  55774. * Gets the steps input component
  55775. */
  55776. readonly steps: NodeMaterialConnectionPoint;
  55777. /**
  55778. * Gets the output component
  55779. */
  55780. readonly output: NodeMaterialConnectionPoint;
  55781. protected _buildBlock(state: NodeMaterialBuildState): this;
  55782. }
  55783. }
  55784. declare module BABYLON {
  55785. /**
  55786. * Operations supported by the Wave block
  55787. */
  55788. export enum WaveBlockKind {
  55789. /** SawTooth */
  55790. SawTooth = 0,
  55791. /** Square */
  55792. Square = 1,
  55793. /** Triangle */
  55794. Triangle = 2
  55795. }
  55796. /**
  55797. * Block used to apply wave operation to floats
  55798. */
  55799. export class WaveBlock extends NodeMaterialBlock {
  55800. /**
  55801. * Gets or sets the kibnd of wave to be applied by the block
  55802. */
  55803. kind: WaveBlockKind;
  55804. /**
  55805. * Creates a new WaveBlock
  55806. * @param name defines the block name
  55807. */
  55808. constructor(name: string);
  55809. /**
  55810. * Gets the current class name
  55811. * @returns the class name
  55812. */
  55813. getClassName(): string;
  55814. /**
  55815. * Gets the input component
  55816. */
  55817. readonly input: NodeMaterialConnectionPoint;
  55818. /**
  55819. * Gets the output component
  55820. */
  55821. readonly output: NodeMaterialConnectionPoint;
  55822. protected _buildBlock(state: NodeMaterialBuildState): this;
  55823. serialize(): any;
  55824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55825. }
  55826. }
  55827. declare module BABYLON {
  55828. /**
  55829. * Class used to store a color step for the GradientBlock
  55830. */
  55831. export class GradientBlockColorStep {
  55832. /**
  55833. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55834. */
  55835. step: number;
  55836. /**
  55837. * Gets or sets the color associated with this step
  55838. */
  55839. color: Color3;
  55840. /**
  55841. * Creates a new GradientBlockColorStep
  55842. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55843. * @param color defines the color associated with this step
  55844. */
  55845. constructor(
  55846. /**
  55847. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55848. */
  55849. step: number,
  55850. /**
  55851. * Gets or sets the color associated with this step
  55852. */
  55853. color: Color3);
  55854. }
  55855. /**
  55856. * Block used to return a color from a gradient based on an input value between 0 and 1
  55857. */
  55858. export class GradientBlock extends NodeMaterialBlock {
  55859. /**
  55860. * Gets or sets the list of color steps
  55861. */
  55862. colorSteps: GradientBlockColorStep[];
  55863. /**
  55864. * Creates a new GradientBlock
  55865. * @param name defines the block name
  55866. */
  55867. constructor(name: string);
  55868. /**
  55869. * Gets the current class name
  55870. * @returns the class name
  55871. */
  55872. getClassName(): string;
  55873. /**
  55874. * Gets the gradient input component
  55875. */
  55876. readonly gradient: NodeMaterialConnectionPoint;
  55877. /**
  55878. * Gets the output component
  55879. */
  55880. readonly output: NodeMaterialConnectionPoint;
  55881. private _writeColorConstant;
  55882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55883. serialize(): any;
  55884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55885. protected _dumpPropertiesCode(): string;
  55886. }
  55887. }
  55888. declare module BABYLON {
  55889. /**
  55890. * Block used to normalize lerp between 2 values
  55891. */
  55892. export class NLerpBlock extends NodeMaterialBlock {
  55893. /**
  55894. * Creates a new NLerpBlock
  55895. * @param name defines the block name
  55896. */
  55897. constructor(name: string);
  55898. /**
  55899. * Gets the current class name
  55900. * @returns the class name
  55901. */
  55902. getClassName(): string;
  55903. /**
  55904. * Gets the left operand input component
  55905. */
  55906. readonly left: NodeMaterialConnectionPoint;
  55907. /**
  55908. * Gets the right operand input component
  55909. */
  55910. readonly right: NodeMaterialConnectionPoint;
  55911. /**
  55912. * Gets the gradient operand input component
  55913. */
  55914. readonly gradient: NodeMaterialConnectionPoint;
  55915. /**
  55916. * Gets the output component
  55917. */
  55918. readonly output: NodeMaterialConnectionPoint;
  55919. protected _buildBlock(state: NodeMaterialBuildState): this;
  55920. }
  55921. }
  55922. declare module BABYLON {
  55923. /**
  55924. * Block used to test if the fragment shader is front facing
  55925. */
  55926. export class FrontFacingBlock extends NodeMaterialBlock {
  55927. /**
  55928. * Creates a new FrontFacingBlock
  55929. * @param name defines the block name
  55930. */
  55931. constructor(name: string);
  55932. /**
  55933. * Gets the current class name
  55934. * @returns the class name
  55935. */
  55936. getClassName(): string;
  55937. /**
  55938. * Gets the world normal component
  55939. */
  55940. readonly worldNormal: NodeMaterialConnectionPoint;
  55941. /**
  55942. * Gets the view direction input component
  55943. */
  55944. readonly viewDirection: NodeMaterialConnectionPoint;
  55945. /**
  55946. * Gets the output component
  55947. */
  55948. readonly output: NodeMaterialConnectionPoint;
  55949. autoConfigure(material: NodeMaterial): void;
  55950. protected _buildBlock(state: NodeMaterialBuildState): this;
  55951. }
  55952. }
  55953. declare module BABYLON {
  55954. /**
  55955. * Effect Render Options
  55956. */
  55957. export interface IEffectRendererOptions {
  55958. /**
  55959. * Defines the vertices positions.
  55960. */
  55961. positions?: number[];
  55962. /**
  55963. * Defines the indices.
  55964. */
  55965. indices?: number[];
  55966. }
  55967. /**
  55968. * Helper class to render one or more effects
  55969. */
  55970. export class EffectRenderer {
  55971. private engine;
  55972. private static _DefaultOptions;
  55973. private _vertexBuffers;
  55974. private _indexBuffer;
  55975. private _ringBufferIndex;
  55976. private _ringScreenBuffer;
  55977. private _fullscreenViewport;
  55978. private _getNextFrameBuffer;
  55979. /**
  55980. * Creates an effect renderer
  55981. * @param engine the engine to use for rendering
  55982. * @param options defines the options of the effect renderer
  55983. */
  55984. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55985. /**
  55986. * Sets the current viewport in normalized coordinates 0-1
  55987. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55988. */
  55989. setViewport(viewport?: Viewport): void;
  55990. /**
  55991. * Binds the embedded attributes buffer to the effect.
  55992. * @param effect Defines the effect to bind the attributes for
  55993. */
  55994. bindBuffers(effect: Effect): void;
  55995. /**
  55996. * Sets the current effect wrapper to use during draw.
  55997. * The effect needs to be ready before calling this api.
  55998. * This also sets the default full screen position attribute.
  55999. * @param effectWrapper Defines the effect to draw with
  56000. */
  56001. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56002. /**
  56003. * Draws a full screen quad.
  56004. */
  56005. draw(): void;
  56006. /**
  56007. * renders one or more effects to a specified texture
  56008. * @param effectWrappers list of effects to renderer
  56009. * @param outputTexture texture to draw to, if null it will render to the screen
  56010. */
  56011. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56012. /**
  56013. * Disposes of the effect renderer
  56014. */
  56015. dispose(): void;
  56016. }
  56017. /**
  56018. * Options to create an EffectWrapper
  56019. */
  56020. interface EffectWrapperCreationOptions {
  56021. /**
  56022. * Engine to use to create the effect
  56023. */
  56024. engine: ThinEngine;
  56025. /**
  56026. * Fragment shader for the effect
  56027. */
  56028. fragmentShader: string;
  56029. /**
  56030. * Vertex shader for the effect
  56031. */
  56032. vertexShader?: string;
  56033. /**
  56034. * Attributes to use in the shader
  56035. */
  56036. attributeNames?: Array<string>;
  56037. /**
  56038. * Uniforms to use in the shader
  56039. */
  56040. uniformNames?: Array<string>;
  56041. /**
  56042. * Texture sampler names to use in the shader
  56043. */
  56044. samplerNames?: Array<string>;
  56045. /**
  56046. * The friendly name of the effect displayed in Spector.
  56047. */
  56048. name?: string;
  56049. }
  56050. /**
  56051. * Wraps an effect to be used for rendering
  56052. */
  56053. export class EffectWrapper {
  56054. /**
  56055. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56056. */
  56057. onApplyObservable: Observable<{}>;
  56058. /**
  56059. * The underlying effect
  56060. */
  56061. effect: Effect;
  56062. /**
  56063. * Creates an effect to be renderer
  56064. * @param creationOptions options to create the effect
  56065. */
  56066. constructor(creationOptions: EffectWrapperCreationOptions);
  56067. /**
  56068. * Disposes of the effect wrapper
  56069. */
  56070. dispose(): void;
  56071. }
  56072. }
  56073. declare module BABYLON {
  56074. /**
  56075. * Helper class to push actions to a pool of workers.
  56076. */
  56077. export class WorkerPool implements IDisposable {
  56078. private _workerInfos;
  56079. private _pendingActions;
  56080. /**
  56081. * Constructor
  56082. * @param workers Array of workers to use for actions
  56083. */
  56084. constructor(workers: Array<Worker>);
  56085. /**
  56086. * Terminates all workers and clears any pending actions.
  56087. */
  56088. dispose(): void;
  56089. /**
  56090. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56091. * pended until a worker has completed its action.
  56092. * @param action The action to perform. Call onComplete when the action is complete.
  56093. */
  56094. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56095. private _execute;
  56096. }
  56097. }
  56098. declare module BABYLON {
  56099. /**
  56100. * Configuration for Draco compression
  56101. */
  56102. export interface IDracoCompressionConfiguration {
  56103. /**
  56104. * Configuration for the decoder.
  56105. */
  56106. decoder: {
  56107. /**
  56108. * The url to the WebAssembly module.
  56109. */
  56110. wasmUrl?: string;
  56111. /**
  56112. * The url to the WebAssembly binary.
  56113. */
  56114. wasmBinaryUrl?: string;
  56115. /**
  56116. * The url to the fallback JavaScript module.
  56117. */
  56118. fallbackUrl?: string;
  56119. };
  56120. }
  56121. /**
  56122. * Draco compression (https://google.github.io/draco/)
  56123. *
  56124. * This class wraps the Draco module.
  56125. *
  56126. * **Encoder**
  56127. *
  56128. * The encoder is not currently implemented.
  56129. *
  56130. * **Decoder**
  56131. *
  56132. * 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.
  56133. *
  56134. * To update the configuration, use the following code:
  56135. * ```javascript
  56136. * DracoCompression.Configuration = {
  56137. * decoder: {
  56138. * wasmUrl: "<url to the WebAssembly library>",
  56139. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56140. * fallbackUrl: "<url to the fallback JavaScript library>",
  56141. * }
  56142. * };
  56143. * ```
  56144. *
  56145. * 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.
  56146. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56147. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56148. *
  56149. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56150. * ```javascript
  56151. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56152. * ```
  56153. *
  56154. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56155. */
  56156. export class DracoCompression implements IDisposable {
  56157. private _workerPoolPromise?;
  56158. private _decoderModulePromise?;
  56159. /**
  56160. * The configuration. Defaults to the following urls:
  56161. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56162. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56163. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56164. */
  56165. static Configuration: IDracoCompressionConfiguration;
  56166. /**
  56167. * Returns true if the decoder configuration is available.
  56168. */
  56169. static readonly DecoderAvailable: boolean;
  56170. /**
  56171. * Default number of workers to create when creating the draco compression object.
  56172. */
  56173. static DefaultNumWorkers: number;
  56174. private static GetDefaultNumWorkers;
  56175. private static _Default;
  56176. /**
  56177. * Default instance for the draco compression object.
  56178. */
  56179. static readonly Default: DracoCompression;
  56180. /**
  56181. * Constructor
  56182. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56183. */
  56184. constructor(numWorkers?: number);
  56185. /**
  56186. * Stop all async operations and release resources.
  56187. */
  56188. dispose(): void;
  56189. /**
  56190. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56191. * @returns a promise that resolves when ready
  56192. */
  56193. whenReadyAsync(): Promise<void>;
  56194. /**
  56195. * Decode Draco compressed mesh data to vertex data.
  56196. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56197. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56198. * @returns A promise that resolves with the decoded vertex data
  56199. */
  56200. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56201. [kind: string]: number;
  56202. }): Promise<VertexData>;
  56203. }
  56204. }
  56205. declare module BABYLON {
  56206. /**
  56207. * Class for building Constructive Solid Geometry
  56208. */
  56209. export class CSG {
  56210. private polygons;
  56211. /**
  56212. * The world matrix
  56213. */
  56214. matrix: Matrix;
  56215. /**
  56216. * Stores the position
  56217. */
  56218. position: Vector3;
  56219. /**
  56220. * Stores the rotation
  56221. */
  56222. rotation: Vector3;
  56223. /**
  56224. * Stores the rotation quaternion
  56225. */
  56226. rotationQuaternion: Nullable<Quaternion>;
  56227. /**
  56228. * Stores the scaling vector
  56229. */
  56230. scaling: Vector3;
  56231. /**
  56232. * Convert the Mesh to CSG
  56233. * @param mesh The Mesh to convert to CSG
  56234. * @returns A new CSG from the Mesh
  56235. */
  56236. static FromMesh(mesh: Mesh): CSG;
  56237. /**
  56238. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56239. * @param polygons Polygons used to construct a CSG solid
  56240. */
  56241. private static FromPolygons;
  56242. /**
  56243. * Clones, or makes a deep copy, of the CSG
  56244. * @returns A new CSG
  56245. */
  56246. clone(): CSG;
  56247. /**
  56248. * Unions this CSG with another CSG
  56249. * @param csg The CSG to union against this CSG
  56250. * @returns The unioned CSG
  56251. */
  56252. union(csg: CSG): CSG;
  56253. /**
  56254. * Unions this CSG with another CSG in place
  56255. * @param csg The CSG to union against this CSG
  56256. */
  56257. unionInPlace(csg: CSG): void;
  56258. /**
  56259. * Subtracts this CSG with another CSG
  56260. * @param csg The CSG to subtract against this CSG
  56261. * @returns A new CSG
  56262. */
  56263. subtract(csg: CSG): CSG;
  56264. /**
  56265. * Subtracts this CSG with another CSG in place
  56266. * @param csg The CSG to subtact against this CSG
  56267. */
  56268. subtractInPlace(csg: CSG): void;
  56269. /**
  56270. * Intersect this CSG with another CSG
  56271. * @param csg The CSG to intersect against this CSG
  56272. * @returns A new CSG
  56273. */
  56274. intersect(csg: CSG): CSG;
  56275. /**
  56276. * Intersects this CSG with another CSG in place
  56277. * @param csg The CSG to intersect against this CSG
  56278. */
  56279. intersectInPlace(csg: CSG): void;
  56280. /**
  56281. * Return a new CSG solid with solid and empty space switched. This solid is
  56282. * not modified.
  56283. * @returns A new CSG solid with solid and empty space switched
  56284. */
  56285. inverse(): CSG;
  56286. /**
  56287. * Inverses the CSG in place
  56288. */
  56289. inverseInPlace(): void;
  56290. /**
  56291. * This is used to keep meshes transformations so they can be restored
  56292. * when we build back a Babylon Mesh
  56293. * NB : All CSG operations are performed in world coordinates
  56294. * @param csg The CSG to copy the transform attributes from
  56295. * @returns This CSG
  56296. */
  56297. copyTransformAttributes(csg: CSG): CSG;
  56298. /**
  56299. * Build Raw mesh from CSG
  56300. * Coordinates here are in world space
  56301. * @param name The name of the mesh geometry
  56302. * @param scene The Scene
  56303. * @param keepSubMeshes Specifies if the submeshes should be kept
  56304. * @returns A new Mesh
  56305. */
  56306. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56307. /**
  56308. * Build Mesh from CSG taking material and transforms into account
  56309. * @param name The name of the Mesh
  56310. * @param material The material of the Mesh
  56311. * @param scene The Scene
  56312. * @param keepSubMeshes Specifies if submeshes should be kept
  56313. * @returns The new Mesh
  56314. */
  56315. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56316. }
  56317. }
  56318. declare module BABYLON {
  56319. /**
  56320. * Class used to create a trail following a mesh
  56321. */
  56322. export class TrailMesh extends Mesh {
  56323. private _generator;
  56324. private _autoStart;
  56325. private _running;
  56326. private _diameter;
  56327. private _length;
  56328. private _sectionPolygonPointsCount;
  56329. private _sectionVectors;
  56330. private _sectionNormalVectors;
  56331. private _beforeRenderObserver;
  56332. /**
  56333. * @constructor
  56334. * @param name The value used by scene.getMeshByName() to do a lookup.
  56335. * @param generator The mesh to generate a trail.
  56336. * @param scene The scene to add this mesh to.
  56337. * @param diameter Diameter of trailing mesh. Default is 1.
  56338. * @param length Length of trailing mesh. Default is 60.
  56339. * @param autoStart Automatically start trailing mesh. Default true.
  56340. */
  56341. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56342. /**
  56343. * "TrailMesh"
  56344. * @returns "TrailMesh"
  56345. */
  56346. getClassName(): string;
  56347. private _createMesh;
  56348. /**
  56349. * Start trailing mesh.
  56350. */
  56351. start(): void;
  56352. /**
  56353. * Stop trailing mesh.
  56354. */
  56355. stop(): void;
  56356. /**
  56357. * Update trailing mesh geometry.
  56358. */
  56359. update(): void;
  56360. /**
  56361. * Returns a new TrailMesh object.
  56362. * @param name is a string, the name given to the new mesh
  56363. * @param newGenerator use new generator object for cloned trail mesh
  56364. * @returns a new mesh
  56365. */
  56366. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56367. /**
  56368. * Serializes this trail mesh
  56369. * @param serializationObject object to write serialization to
  56370. */
  56371. serialize(serializationObject: any): void;
  56372. /**
  56373. * Parses a serialized trail mesh
  56374. * @param parsedMesh the serialized mesh
  56375. * @param scene the scene to create the trail mesh in
  56376. * @returns the created trail mesh
  56377. */
  56378. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56379. }
  56380. }
  56381. declare module BABYLON {
  56382. /**
  56383. * Class containing static functions to help procedurally build meshes
  56384. */
  56385. export class TiledBoxBuilder {
  56386. /**
  56387. * Creates a box mesh
  56388. * 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)
  56389. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56391. * * 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
  56392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56393. * @param name defines the name of the mesh
  56394. * @param options defines the options used to create the mesh
  56395. * @param scene defines the hosting scene
  56396. * @returns the box mesh
  56397. */
  56398. static CreateTiledBox(name: string, options: {
  56399. pattern?: number;
  56400. width?: number;
  56401. height?: number;
  56402. depth?: number;
  56403. tileSize?: number;
  56404. tileWidth?: number;
  56405. tileHeight?: number;
  56406. alignHorizontal?: number;
  56407. alignVertical?: number;
  56408. faceUV?: Vector4[];
  56409. faceColors?: Color4[];
  56410. sideOrientation?: number;
  56411. updatable?: boolean;
  56412. }, scene?: Nullable<Scene>): Mesh;
  56413. }
  56414. }
  56415. declare module BABYLON {
  56416. /**
  56417. * Class containing static functions to help procedurally build meshes
  56418. */
  56419. export class TorusKnotBuilder {
  56420. /**
  56421. * Creates a torus knot mesh
  56422. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56423. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56424. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56425. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56427. * * 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
  56428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56429. * @param name defines the name of the mesh
  56430. * @param options defines the options used to create the mesh
  56431. * @param scene defines the hosting scene
  56432. * @returns the torus knot mesh
  56433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56434. */
  56435. static CreateTorusKnot(name: string, options: {
  56436. radius?: number;
  56437. tube?: number;
  56438. radialSegments?: number;
  56439. tubularSegments?: number;
  56440. p?: number;
  56441. q?: number;
  56442. updatable?: boolean;
  56443. sideOrientation?: number;
  56444. frontUVs?: Vector4;
  56445. backUVs?: Vector4;
  56446. }, scene: any): Mesh;
  56447. }
  56448. }
  56449. declare module BABYLON {
  56450. /**
  56451. * Polygon
  56452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56453. */
  56454. export class Polygon {
  56455. /**
  56456. * Creates a rectangle
  56457. * @param xmin bottom X coord
  56458. * @param ymin bottom Y coord
  56459. * @param xmax top X coord
  56460. * @param ymax top Y coord
  56461. * @returns points that make the resulting rectation
  56462. */
  56463. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56464. /**
  56465. * Creates a circle
  56466. * @param radius radius of circle
  56467. * @param cx scale in x
  56468. * @param cy scale in y
  56469. * @param numberOfSides number of sides that make up the circle
  56470. * @returns points that make the resulting circle
  56471. */
  56472. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56473. /**
  56474. * Creates a polygon from input string
  56475. * @param input Input polygon data
  56476. * @returns the parsed points
  56477. */
  56478. static Parse(input: string): Vector2[];
  56479. /**
  56480. * Starts building a polygon from x and y coordinates
  56481. * @param x x coordinate
  56482. * @param y y coordinate
  56483. * @returns the started path2
  56484. */
  56485. static StartingAt(x: number, y: number): Path2;
  56486. }
  56487. /**
  56488. * Builds a polygon
  56489. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56490. */
  56491. export class PolygonMeshBuilder {
  56492. private _points;
  56493. private _outlinepoints;
  56494. private _holes;
  56495. private _name;
  56496. private _scene;
  56497. private _epoints;
  56498. private _eholes;
  56499. private _addToepoint;
  56500. /**
  56501. * Babylon reference to the earcut plugin.
  56502. */
  56503. bjsEarcut: any;
  56504. /**
  56505. * Creates a PolygonMeshBuilder
  56506. * @param name name of the builder
  56507. * @param contours Path of the polygon
  56508. * @param scene scene to add to when creating the mesh
  56509. * @param earcutInjection can be used to inject your own earcut reference
  56510. */
  56511. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56512. /**
  56513. * Adds a whole within the polygon
  56514. * @param hole Array of points defining the hole
  56515. * @returns this
  56516. */
  56517. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56518. /**
  56519. * Creates the polygon
  56520. * @param updatable If the mesh should be updatable
  56521. * @param depth The depth of the mesh created
  56522. * @returns the created mesh
  56523. */
  56524. build(updatable?: boolean, depth?: number): Mesh;
  56525. /**
  56526. * Creates the polygon
  56527. * @param depth The depth of the mesh created
  56528. * @returns the created VertexData
  56529. */
  56530. buildVertexData(depth?: number): VertexData;
  56531. /**
  56532. * Adds a side to the polygon
  56533. * @param positions points that make the polygon
  56534. * @param normals normals of the polygon
  56535. * @param uvs uvs of the polygon
  56536. * @param indices indices of the polygon
  56537. * @param bounds bounds of the polygon
  56538. * @param points points of the polygon
  56539. * @param depth depth of the polygon
  56540. * @param flip flip of the polygon
  56541. */
  56542. private addSide;
  56543. }
  56544. }
  56545. declare module BABYLON {
  56546. /**
  56547. * Class containing static functions to help procedurally build meshes
  56548. */
  56549. export class PolygonBuilder {
  56550. /**
  56551. * Creates a polygon mesh
  56552. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56553. * * 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
  56554. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56556. * * 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)
  56557. * * Remember you can only change the shape positions, not their number when updating a polygon
  56558. * @param name defines the name of the mesh
  56559. * @param options defines the options used to create the mesh
  56560. * @param scene defines the hosting scene
  56561. * @param earcutInjection can be used to inject your own earcut reference
  56562. * @returns the polygon mesh
  56563. */
  56564. static CreatePolygon(name: string, options: {
  56565. shape: Vector3[];
  56566. holes?: Vector3[][];
  56567. depth?: number;
  56568. faceUV?: Vector4[];
  56569. faceColors?: Color4[];
  56570. updatable?: boolean;
  56571. sideOrientation?: number;
  56572. frontUVs?: Vector4;
  56573. backUVs?: Vector4;
  56574. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56575. /**
  56576. * Creates an extruded polygon mesh, with depth in the Y direction.
  56577. * * 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)
  56578. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56579. * @param name defines the name of the mesh
  56580. * @param options defines the options used to create the mesh
  56581. * @param scene defines the hosting scene
  56582. * @param earcutInjection can be used to inject your own earcut reference
  56583. * @returns the polygon mesh
  56584. */
  56585. static ExtrudePolygon(name: string, options: {
  56586. shape: Vector3[];
  56587. holes?: Vector3[][];
  56588. depth?: number;
  56589. faceUV?: Vector4[];
  56590. faceColors?: Color4[];
  56591. updatable?: boolean;
  56592. sideOrientation?: number;
  56593. frontUVs?: Vector4;
  56594. backUVs?: Vector4;
  56595. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56596. }
  56597. }
  56598. declare module BABYLON {
  56599. /**
  56600. * Class containing static functions to help procedurally build meshes
  56601. */
  56602. export class LatheBuilder {
  56603. /**
  56604. * Creates lathe mesh.
  56605. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56606. * * 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
  56607. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56608. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56609. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56610. * * 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
  56611. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56612. * * 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
  56613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56614. * * 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
  56615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56617. * @param name defines the name of the mesh
  56618. * @param options defines the options used to create the mesh
  56619. * @param scene defines the hosting scene
  56620. * @returns the lathe mesh
  56621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56622. */
  56623. static CreateLathe(name: string, options: {
  56624. shape: Vector3[];
  56625. radius?: number;
  56626. tessellation?: number;
  56627. clip?: number;
  56628. arc?: number;
  56629. closed?: boolean;
  56630. updatable?: boolean;
  56631. sideOrientation?: number;
  56632. frontUVs?: Vector4;
  56633. backUVs?: Vector4;
  56634. cap?: number;
  56635. invertUV?: boolean;
  56636. }, scene?: Nullable<Scene>): Mesh;
  56637. }
  56638. }
  56639. declare module BABYLON {
  56640. /**
  56641. * Class containing static functions to help procedurally build meshes
  56642. */
  56643. export class TiledPlaneBuilder {
  56644. /**
  56645. * Creates a tiled plane mesh
  56646. * * The parameter `pattern` will, depending on value, do nothing or
  56647. * * * flip (reflect about central vertical) alternate tiles across and up
  56648. * * * flip every tile on alternate rows
  56649. * * * rotate (180 degs) alternate tiles across and up
  56650. * * * rotate every tile on alternate rows
  56651. * * * flip and rotate alternate tiles across and up
  56652. * * * flip and rotate every tile on alternate rows
  56653. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56654. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56655. * * 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
  56656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56657. * * 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)
  56658. * * 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)
  56659. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56660. * @param name defines the name of the mesh
  56661. * @param options defines the options used to create the mesh
  56662. * @param scene defines the hosting scene
  56663. * @returns the box mesh
  56664. */
  56665. static CreateTiledPlane(name: string, options: {
  56666. pattern?: number;
  56667. tileSize?: number;
  56668. tileWidth?: number;
  56669. tileHeight?: number;
  56670. size?: number;
  56671. width?: number;
  56672. height?: number;
  56673. alignHorizontal?: number;
  56674. alignVertical?: number;
  56675. sideOrientation?: number;
  56676. frontUVs?: Vector4;
  56677. backUVs?: Vector4;
  56678. updatable?: boolean;
  56679. }, scene?: Nullable<Scene>): Mesh;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Class containing static functions to help procedurally build meshes
  56685. */
  56686. export class TubeBuilder {
  56687. /**
  56688. * Creates a tube mesh.
  56689. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56690. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56691. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56692. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56693. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56694. * * 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)
  56695. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56696. * * 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
  56697. * * 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
  56698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56699. * * 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
  56700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56702. * @param name defines the name of the mesh
  56703. * @param options defines the options used to create the mesh
  56704. * @param scene defines the hosting scene
  56705. * @returns the tube mesh
  56706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56707. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56708. */
  56709. static CreateTube(name: string, options: {
  56710. path: Vector3[];
  56711. radius?: number;
  56712. tessellation?: number;
  56713. radiusFunction?: {
  56714. (i: number, distance: number): number;
  56715. };
  56716. cap?: number;
  56717. arc?: number;
  56718. updatable?: boolean;
  56719. sideOrientation?: number;
  56720. frontUVs?: Vector4;
  56721. backUVs?: Vector4;
  56722. instance?: Mesh;
  56723. invertUV?: boolean;
  56724. }, scene?: Nullable<Scene>): Mesh;
  56725. }
  56726. }
  56727. declare module BABYLON {
  56728. /**
  56729. * Class containing static functions to help procedurally build meshes
  56730. */
  56731. export class IcoSphereBuilder {
  56732. /**
  56733. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56734. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56735. * * 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`)
  56736. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56737. * * 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
  56738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56739. * * 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
  56740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56741. * @param name defines the name of the mesh
  56742. * @param options defines the options used to create the mesh
  56743. * @param scene defines the hosting scene
  56744. * @returns the icosahedron mesh
  56745. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56746. */
  56747. static CreateIcoSphere(name: string, options: {
  56748. radius?: number;
  56749. radiusX?: number;
  56750. radiusY?: number;
  56751. radiusZ?: number;
  56752. flat?: boolean;
  56753. subdivisions?: number;
  56754. sideOrientation?: number;
  56755. frontUVs?: Vector4;
  56756. backUVs?: Vector4;
  56757. updatable?: boolean;
  56758. }, scene?: Nullable<Scene>): Mesh;
  56759. }
  56760. }
  56761. declare module BABYLON {
  56762. /**
  56763. * Class containing static functions to help procedurally build meshes
  56764. */
  56765. export class DecalBuilder {
  56766. /**
  56767. * Creates a decal mesh.
  56768. * 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
  56769. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56770. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56771. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56772. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56773. * @param name defines the name of the mesh
  56774. * @param sourceMesh defines the mesh where the decal must be applied
  56775. * @param options defines the options used to create the mesh
  56776. * @param scene defines the hosting scene
  56777. * @returns the decal mesh
  56778. * @see https://doc.babylonjs.com/how_to/decals
  56779. */
  56780. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56781. position?: Vector3;
  56782. normal?: Vector3;
  56783. size?: Vector3;
  56784. angle?: number;
  56785. }): Mesh;
  56786. }
  56787. }
  56788. declare module BABYLON {
  56789. /**
  56790. * Class containing static functions to help procedurally build meshes
  56791. */
  56792. export class MeshBuilder {
  56793. /**
  56794. * Creates a box mesh
  56795. * * The parameter `size` sets the size (float) of each box side (default 1)
  56796. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56797. * * 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)
  56798. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56800. * * 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
  56801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56802. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56803. * @param name defines the name of the mesh
  56804. * @param options defines the options used to create the mesh
  56805. * @param scene defines the hosting scene
  56806. * @returns the box mesh
  56807. */
  56808. static CreateBox(name: string, options: {
  56809. size?: number;
  56810. width?: number;
  56811. height?: number;
  56812. depth?: number;
  56813. faceUV?: Vector4[];
  56814. faceColors?: Color4[];
  56815. sideOrientation?: number;
  56816. frontUVs?: Vector4;
  56817. backUVs?: Vector4;
  56818. updatable?: boolean;
  56819. }, scene?: Nullable<Scene>): Mesh;
  56820. /**
  56821. * Creates a tiled box mesh
  56822. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56824. * @param name defines the name of the mesh
  56825. * @param options defines the options used to create the mesh
  56826. * @param scene defines the hosting scene
  56827. * @returns the tiled box mesh
  56828. */
  56829. static CreateTiledBox(name: string, options: {
  56830. pattern?: number;
  56831. size?: number;
  56832. width?: number;
  56833. height?: number;
  56834. depth: number;
  56835. tileSize?: number;
  56836. tileWidth?: number;
  56837. tileHeight?: number;
  56838. faceUV?: Vector4[];
  56839. faceColors?: Color4[];
  56840. alignHorizontal?: number;
  56841. alignVertical?: number;
  56842. sideOrientation?: number;
  56843. updatable?: boolean;
  56844. }, scene?: Nullable<Scene>): Mesh;
  56845. /**
  56846. * Creates a sphere mesh
  56847. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56848. * * 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`)
  56849. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56850. * * 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
  56851. * * 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)
  56852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56853. * * 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
  56854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56855. * @param name defines the name of the mesh
  56856. * @param options defines the options used to create the mesh
  56857. * @param scene defines the hosting scene
  56858. * @returns the sphere mesh
  56859. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56860. */
  56861. static CreateSphere(name: string, options: {
  56862. segments?: number;
  56863. diameter?: number;
  56864. diameterX?: number;
  56865. diameterY?: number;
  56866. diameterZ?: number;
  56867. arc?: number;
  56868. slice?: number;
  56869. sideOrientation?: number;
  56870. frontUVs?: Vector4;
  56871. backUVs?: Vector4;
  56872. updatable?: boolean;
  56873. }, scene?: Nullable<Scene>): Mesh;
  56874. /**
  56875. * Creates a plane polygonal mesh. By default, this is a disc
  56876. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56877. * * 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
  56878. * * 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
  56879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56880. * * 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
  56881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56882. * @param name defines the name of the mesh
  56883. * @param options defines the options used to create the mesh
  56884. * @param scene defines the hosting scene
  56885. * @returns the plane polygonal mesh
  56886. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56887. */
  56888. static CreateDisc(name: string, options: {
  56889. radius?: number;
  56890. tessellation?: number;
  56891. arc?: number;
  56892. updatable?: boolean;
  56893. sideOrientation?: number;
  56894. frontUVs?: Vector4;
  56895. backUVs?: Vector4;
  56896. }, scene?: Nullable<Scene>): Mesh;
  56897. /**
  56898. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56899. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56900. * * 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`)
  56901. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56902. * * 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
  56903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56904. * * 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
  56905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56906. * @param name defines the name of the mesh
  56907. * @param options defines the options used to create the mesh
  56908. * @param scene defines the hosting scene
  56909. * @returns the icosahedron mesh
  56910. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56911. */
  56912. static CreateIcoSphere(name: string, options: {
  56913. radius?: number;
  56914. radiusX?: number;
  56915. radiusY?: number;
  56916. radiusZ?: number;
  56917. flat?: boolean;
  56918. subdivisions?: number;
  56919. sideOrientation?: number;
  56920. frontUVs?: Vector4;
  56921. backUVs?: Vector4;
  56922. updatable?: boolean;
  56923. }, scene?: Nullable<Scene>): Mesh;
  56924. /**
  56925. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56926. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56927. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56928. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56929. * * 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
  56930. * * 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
  56931. * * 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
  56932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56933. * * 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
  56934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56935. * * 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
  56936. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56937. * * 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
  56938. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56940. * @param name defines the name of the mesh
  56941. * @param options defines the options used to create the mesh
  56942. * @param scene defines the hosting scene
  56943. * @returns the ribbon mesh
  56944. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56946. */
  56947. static CreateRibbon(name: string, options: {
  56948. pathArray: Vector3[][];
  56949. closeArray?: boolean;
  56950. closePath?: boolean;
  56951. offset?: number;
  56952. updatable?: boolean;
  56953. sideOrientation?: number;
  56954. frontUVs?: Vector4;
  56955. backUVs?: Vector4;
  56956. instance?: Mesh;
  56957. invertUV?: boolean;
  56958. uvs?: Vector2[];
  56959. colors?: Color4[];
  56960. }, scene?: Nullable<Scene>): Mesh;
  56961. /**
  56962. * Creates a cylinder or a cone mesh
  56963. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56964. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56965. * * 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.
  56966. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56967. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56968. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56969. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56970. * * 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).
  56971. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56972. * * 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).
  56973. * * 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
  56974. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56975. * * 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
  56976. * * 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.
  56977. * * If `enclose` is false, a ring surface is one element.
  56978. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56979. * * 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
  56980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56981. * * 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
  56982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56983. * @param name defines the name of the mesh
  56984. * @param options defines the options used to create the mesh
  56985. * @param scene defines the hosting scene
  56986. * @returns the cylinder mesh
  56987. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56988. */
  56989. static CreateCylinder(name: string, options: {
  56990. height?: number;
  56991. diameterTop?: number;
  56992. diameterBottom?: number;
  56993. diameter?: number;
  56994. tessellation?: number;
  56995. subdivisions?: number;
  56996. arc?: number;
  56997. faceColors?: Color4[];
  56998. faceUV?: Vector4[];
  56999. updatable?: boolean;
  57000. hasRings?: boolean;
  57001. enclose?: boolean;
  57002. cap?: number;
  57003. sideOrientation?: number;
  57004. frontUVs?: Vector4;
  57005. backUVs?: Vector4;
  57006. }, scene?: Nullable<Scene>): Mesh;
  57007. /**
  57008. * Creates a torus mesh
  57009. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57010. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57011. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57013. * * 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
  57014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57015. * @param name defines the name of the mesh
  57016. * @param options defines the options used to create the mesh
  57017. * @param scene defines the hosting scene
  57018. * @returns the torus mesh
  57019. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57020. */
  57021. static CreateTorus(name: string, options: {
  57022. diameter?: number;
  57023. thickness?: number;
  57024. tessellation?: number;
  57025. updatable?: boolean;
  57026. sideOrientation?: number;
  57027. frontUVs?: Vector4;
  57028. backUVs?: Vector4;
  57029. }, scene?: Nullable<Scene>): Mesh;
  57030. /**
  57031. * Creates a torus knot mesh
  57032. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57033. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57034. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57035. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57037. * * 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
  57038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57039. * @param name defines the name of the mesh
  57040. * @param options defines the options used to create the mesh
  57041. * @param scene defines the hosting scene
  57042. * @returns the torus knot mesh
  57043. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57044. */
  57045. static CreateTorusKnot(name: string, options: {
  57046. radius?: number;
  57047. tube?: number;
  57048. radialSegments?: number;
  57049. tubularSegments?: number;
  57050. p?: number;
  57051. q?: number;
  57052. updatable?: boolean;
  57053. sideOrientation?: number;
  57054. frontUVs?: Vector4;
  57055. backUVs?: Vector4;
  57056. }, scene?: Nullable<Scene>): Mesh;
  57057. /**
  57058. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57059. * * 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
  57060. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57061. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57062. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57063. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57064. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57065. * * 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
  57066. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57069. * @param name defines the name of the new line system
  57070. * @param options defines the options used to create the line system
  57071. * @param scene defines the hosting scene
  57072. * @returns a new line system mesh
  57073. */
  57074. static CreateLineSystem(name: string, options: {
  57075. lines: Vector3[][];
  57076. updatable?: boolean;
  57077. instance?: Nullable<LinesMesh>;
  57078. colors?: Nullable<Color4[][]>;
  57079. useVertexAlpha?: boolean;
  57080. }, scene: Nullable<Scene>): LinesMesh;
  57081. /**
  57082. * Creates a line mesh
  57083. * 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
  57084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57085. * * The parameter `points` is an array successive Vector3
  57086. * * 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
  57087. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57088. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57089. * * When updating an instance, remember that only point positions can change, not the number of points
  57090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57092. * @param name defines the name of the new line system
  57093. * @param options defines the options used to create the line system
  57094. * @param scene defines the hosting scene
  57095. * @returns a new line mesh
  57096. */
  57097. static CreateLines(name: string, options: {
  57098. points: Vector3[];
  57099. updatable?: boolean;
  57100. instance?: Nullable<LinesMesh>;
  57101. colors?: Color4[];
  57102. useVertexAlpha?: boolean;
  57103. }, scene?: Nullable<Scene>): LinesMesh;
  57104. /**
  57105. * Creates a dashed line mesh
  57106. * * 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
  57107. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57108. * * The parameter `points` is an array successive Vector3
  57109. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57110. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57111. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57112. * * 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
  57113. * * When updating an instance, remember that only point positions can change, not the number of points
  57114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57115. * @param name defines the name of the mesh
  57116. * @param options defines the options used to create the mesh
  57117. * @param scene defines the hosting scene
  57118. * @returns the dashed line mesh
  57119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57120. */
  57121. static CreateDashedLines(name: string, options: {
  57122. points: Vector3[];
  57123. dashSize?: number;
  57124. gapSize?: number;
  57125. dashNb?: number;
  57126. updatable?: boolean;
  57127. instance?: LinesMesh;
  57128. }, scene?: Nullable<Scene>): LinesMesh;
  57129. /**
  57130. * 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.
  57131. * * 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.
  57132. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57133. * * 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.
  57134. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57135. * * 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
  57136. * * 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
  57137. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57139. * * 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
  57140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57142. * @param name defines the name of the mesh
  57143. * @param options defines the options used to create the mesh
  57144. * @param scene defines the hosting scene
  57145. * @returns the extruded shape mesh
  57146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57148. */
  57149. static ExtrudeShape(name: string, options: {
  57150. shape: Vector3[];
  57151. path: Vector3[];
  57152. scale?: number;
  57153. rotation?: number;
  57154. cap?: number;
  57155. updatable?: boolean;
  57156. sideOrientation?: number;
  57157. frontUVs?: Vector4;
  57158. backUVs?: Vector4;
  57159. instance?: Mesh;
  57160. invertUV?: boolean;
  57161. }, scene?: Nullable<Scene>): Mesh;
  57162. /**
  57163. * Creates an custom extruded shape mesh.
  57164. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57165. * * 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.
  57166. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57167. * * 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
  57168. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57169. * * 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
  57170. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57171. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57172. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57173. * * 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
  57174. * * 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
  57175. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57177. * * 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
  57178. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57180. * @param name defines the name of the mesh
  57181. * @param options defines the options used to create the mesh
  57182. * @param scene defines the hosting scene
  57183. * @returns the custom extruded shape mesh
  57184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57187. */
  57188. static ExtrudeShapeCustom(name: string, options: {
  57189. shape: Vector3[];
  57190. path: Vector3[];
  57191. scaleFunction?: any;
  57192. rotationFunction?: any;
  57193. ribbonCloseArray?: boolean;
  57194. ribbonClosePath?: boolean;
  57195. cap?: number;
  57196. updatable?: boolean;
  57197. sideOrientation?: number;
  57198. frontUVs?: Vector4;
  57199. backUVs?: Vector4;
  57200. instance?: Mesh;
  57201. invertUV?: boolean;
  57202. }, scene?: Nullable<Scene>): Mesh;
  57203. /**
  57204. * Creates lathe mesh.
  57205. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57206. * * 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
  57207. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57208. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57209. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57210. * * 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
  57211. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57212. * * 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
  57213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57214. * * 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
  57215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57217. * @param name defines the name of the mesh
  57218. * @param options defines the options used to create the mesh
  57219. * @param scene defines the hosting scene
  57220. * @returns the lathe mesh
  57221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57222. */
  57223. static CreateLathe(name: string, options: {
  57224. shape: Vector3[];
  57225. radius?: number;
  57226. tessellation?: number;
  57227. clip?: number;
  57228. arc?: number;
  57229. closed?: boolean;
  57230. updatable?: boolean;
  57231. sideOrientation?: number;
  57232. frontUVs?: Vector4;
  57233. backUVs?: Vector4;
  57234. cap?: number;
  57235. invertUV?: boolean;
  57236. }, scene?: Nullable<Scene>): Mesh;
  57237. /**
  57238. * Creates a tiled plane mesh
  57239. * * You can set a limited pattern arrangement with the tiles
  57240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57241. * * 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
  57242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57243. * @param name defines the name of the mesh
  57244. * @param options defines the options used to create the mesh
  57245. * @param scene defines the hosting scene
  57246. * @returns the plane mesh
  57247. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57248. */
  57249. static CreateTiledPlane(name: string, options: {
  57250. pattern?: number;
  57251. tileSize?: number;
  57252. tileWidth?: number;
  57253. tileHeight?: number;
  57254. size?: number;
  57255. width?: number;
  57256. height?: number;
  57257. alignHorizontal?: number;
  57258. alignVertical?: number;
  57259. sideOrientation?: number;
  57260. frontUVs?: Vector4;
  57261. backUVs?: Vector4;
  57262. updatable?: boolean;
  57263. }, scene?: Nullable<Scene>): Mesh;
  57264. /**
  57265. * Creates a plane mesh
  57266. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57267. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57268. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57270. * * 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
  57271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57272. * @param name defines the name of the mesh
  57273. * @param options defines the options used to create the mesh
  57274. * @param scene defines the hosting scene
  57275. * @returns the plane mesh
  57276. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57277. */
  57278. static CreatePlane(name: string, options: {
  57279. size?: number;
  57280. width?: number;
  57281. height?: number;
  57282. sideOrientation?: number;
  57283. frontUVs?: Vector4;
  57284. backUVs?: Vector4;
  57285. updatable?: boolean;
  57286. sourcePlane?: Plane;
  57287. }, scene?: Nullable<Scene>): Mesh;
  57288. /**
  57289. * Creates a ground mesh
  57290. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57291. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57293. * @param name defines the name of the mesh
  57294. * @param options defines the options used to create the mesh
  57295. * @param scene defines the hosting scene
  57296. * @returns the ground mesh
  57297. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57298. */
  57299. static CreateGround(name: string, options: {
  57300. width?: number;
  57301. height?: number;
  57302. subdivisions?: number;
  57303. subdivisionsX?: number;
  57304. subdivisionsY?: number;
  57305. updatable?: boolean;
  57306. }, scene?: Nullable<Scene>): Mesh;
  57307. /**
  57308. * Creates a tiled ground mesh
  57309. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57310. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57311. * * 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
  57312. * * 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
  57313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57314. * @param name defines the name of the mesh
  57315. * @param options defines the options used to create the mesh
  57316. * @param scene defines the hosting scene
  57317. * @returns the tiled ground mesh
  57318. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57319. */
  57320. static CreateTiledGround(name: string, options: {
  57321. xmin: number;
  57322. zmin: number;
  57323. xmax: number;
  57324. zmax: number;
  57325. subdivisions?: {
  57326. w: number;
  57327. h: number;
  57328. };
  57329. precision?: {
  57330. w: number;
  57331. h: number;
  57332. };
  57333. updatable?: boolean;
  57334. }, scene?: Nullable<Scene>): Mesh;
  57335. /**
  57336. * Creates a ground mesh from a height map
  57337. * * The parameter `url` sets the URL of the height map image resource.
  57338. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57339. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57340. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57341. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57342. * * 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.
  57343. * * 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).
  57344. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57346. * @param name defines the name of the mesh
  57347. * @param url defines the url to the height map
  57348. * @param options defines the options used to create the mesh
  57349. * @param scene defines the hosting scene
  57350. * @returns the ground mesh
  57351. * @see https://doc.babylonjs.com/babylon101/height_map
  57352. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57353. */
  57354. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57355. width?: number;
  57356. height?: number;
  57357. subdivisions?: number;
  57358. minHeight?: number;
  57359. maxHeight?: number;
  57360. colorFilter?: Color3;
  57361. alphaFilter?: number;
  57362. updatable?: boolean;
  57363. onReady?: (mesh: GroundMesh) => void;
  57364. }, scene?: Nullable<Scene>): GroundMesh;
  57365. /**
  57366. * Creates a polygon mesh
  57367. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57368. * * 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
  57369. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57371. * * 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)
  57372. * * Remember you can only change the shape positions, not their number when updating a polygon
  57373. * @param name defines the name of the mesh
  57374. * @param options defines the options used to create the mesh
  57375. * @param scene defines the hosting scene
  57376. * @param earcutInjection can be used to inject your own earcut reference
  57377. * @returns the polygon mesh
  57378. */
  57379. static CreatePolygon(name: string, options: {
  57380. shape: Vector3[];
  57381. holes?: Vector3[][];
  57382. depth?: number;
  57383. faceUV?: Vector4[];
  57384. faceColors?: Color4[];
  57385. updatable?: boolean;
  57386. sideOrientation?: number;
  57387. frontUVs?: Vector4;
  57388. backUVs?: Vector4;
  57389. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57390. /**
  57391. * Creates an extruded polygon mesh, with depth in the Y direction.
  57392. * * 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)
  57393. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57394. * @param name defines the name of the mesh
  57395. * @param options defines the options used to create the mesh
  57396. * @param scene defines the hosting scene
  57397. * @param earcutInjection can be used to inject your own earcut reference
  57398. * @returns the polygon mesh
  57399. */
  57400. static ExtrudePolygon(name: string, options: {
  57401. shape: Vector3[];
  57402. holes?: Vector3[][];
  57403. depth?: number;
  57404. faceUV?: Vector4[];
  57405. faceColors?: Color4[];
  57406. updatable?: boolean;
  57407. sideOrientation?: number;
  57408. frontUVs?: Vector4;
  57409. backUVs?: Vector4;
  57410. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57411. /**
  57412. * Creates a tube mesh.
  57413. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57414. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57415. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57416. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57417. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57418. * * 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)
  57419. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57420. * * 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
  57421. * * 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
  57422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57423. * * 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
  57424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57426. * @param name defines the name of the mesh
  57427. * @param options defines the options used to create the mesh
  57428. * @param scene defines the hosting scene
  57429. * @returns the tube mesh
  57430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57431. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57432. */
  57433. static CreateTube(name: string, options: {
  57434. path: Vector3[];
  57435. radius?: number;
  57436. tessellation?: number;
  57437. radiusFunction?: {
  57438. (i: number, distance: number): number;
  57439. };
  57440. cap?: number;
  57441. arc?: number;
  57442. updatable?: boolean;
  57443. sideOrientation?: number;
  57444. frontUVs?: Vector4;
  57445. backUVs?: Vector4;
  57446. instance?: Mesh;
  57447. invertUV?: boolean;
  57448. }, scene?: Nullable<Scene>): Mesh;
  57449. /**
  57450. * Creates a polyhedron mesh
  57451. * * 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
  57452. * * The parameter `size` (positive float, default 1) sets the polygon size
  57453. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57454. * * 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`
  57455. * * 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
  57456. * * 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)`)
  57457. * * 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
  57458. * * 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
  57459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57460. * * 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
  57461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57462. * @param name defines the name of the mesh
  57463. * @param options defines the options used to create the mesh
  57464. * @param scene defines the hosting scene
  57465. * @returns the polyhedron mesh
  57466. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57467. */
  57468. static CreatePolyhedron(name: string, options: {
  57469. type?: number;
  57470. size?: number;
  57471. sizeX?: number;
  57472. sizeY?: number;
  57473. sizeZ?: number;
  57474. custom?: any;
  57475. faceUV?: Vector4[];
  57476. faceColors?: Color4[];
  57477. flat?: boolean;
  57478. updatable?: boolean;
  57479. sideOrientation?: number;
  57480. frontUVs?: Vector4;
  57481. backUVs?: Vector4;
  57482. }, scene?: Nullable<Scene>): Mesh;
  57483. /**
  57484. * Creates a decal mesh.
  57485. * 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
  57486. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57487. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57488. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57489. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57490. * @param name defines the name of the mesh
  57491. * @param sourceMesh defines the mesh where the decal must be applied
  57492. * @param options defines the options used to create the mesh
  57493. * @param scene defines the hosting scene
  57494. * @returns the decal mesh
  57495. * @see https://doc.babylonjs.com/how_to/decals
  57496. */
  57497. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57498. position?: Vector3;
  57499. normal?: Vector3;
  57500. size?: Vector3;
  57501. angle?: number;
  57502. }): Mesh;
  57503. }
  57504. }
  57505. declare module BABYLON {
  57506. /**
  57507. * A simplifier interface for future simplification implementations
  57508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57509. */
  57510. export interface ISimplifier {
  57511. /**
  57512. * Simplification of a given mesh according to the given settings.
  57513. * Since this requires computation, it is assumed that the function runs async.
  57514. * @param settings The settings of the simplification, including quality and distance
  57515. * @param successCallback A callback that will be called after the mesh was simplified.
  57516. * @param errorCallback in case of an error, this callback will be called. optional.
  57517. */
  57518. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57519. }
  57520. /**
  57521. * Expected simplification settings.
  57522. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57523. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57524. */
  57525. export interface ISimplificationSettings {
  57526. /**
  57527. * Gets or sets the expected quality
  57528. */
  57529. quality: number;
  57530. /**
  57531. * Gets or sets the distance when this optimized version should be used
  57532. */
  57533. distance: number;
  57534. /**
  57535. * Gets an already optimized mesh
  57536. */
  57537. optimizeMesh?: boolean;
  57538. }
  57539. /**
  57540. * Class used to specify simplification options
  57541. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57542. */
  57543. export class SimplificationSettings implements ISimplificationSettings {
  57544. /** expected quality */
  57545. quality: number;
  57546. /** distance when this optimized version should be used */
  57547. distance: number;
  57548. /** already optimized mesh */
  57549. optimizeMesh?: boolean | undefined;
  57550. /**
  57551. * Creates a SimplificationSettings
  57552. * @param quality expected quality
  57553. * @param distance distance when this optimized version should be used
  57554. * @param optimizeMesh already optimized mesh
  57555. */
  57556. constructor(
  57557. /** expected quality */
  57558. quality: number,
  57559. /** distance when this optimized version should be used */
  57560. distance: number,
  57561. /** already optimized mesh */
  57562. optimizeMesh?: boolean | undefined);
  57563. }
  57564. /**
  57565. * Interface used to define a simplification task
  57566. */
  57567. export interface ISimplificationTask {
  57568. /**
  57569. * Array of settings
  57570. */
  57571. settings: Array<ISimplificationSettings>;
  57572. /**
  57573. * Simplification type
  57574. */
  57575. simplificationType: SimplificationType;
  57576. /**
  57577. * Mesh to simplify
  57578. */
  57579. mesh: Mesh;
  57580. /**
  57581. * Callback called on success
  57582. */
  57583. successCallback?: () => void;
  57584. /**
  57585. * Defines if parallel processing can be used
  57586. */
  57587. parallelProcessing: boolean;
  57588. }
  57589. /**
  57590. * Queue used to order the simplification tasks
  57591. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57592. */
  57593. export class SimplificationQueue {
  57594. private _simplificationArray;
  57595. /**
  57596. * Gets a boolean indicating that the process is still running
  57597. */
  57598. running: boolean;
  57599. /**
  57600. * Creates a new queue
  57601. */
  57602. constructor();
  57603. /**
  57604. * Adds a new simplification task
  57605. * @param task defines a task to add
  57606. */
  57607. addTask(task: ISimplificationTask): void;
  57608. /**
  57609. * Execute next task
  57610. */
  57611. executeNext(): void;
  57612. /**
  57613. * Execute a simplification task
  57614. * @param task defines the task to run
  57615. */
  57616. runSimplification(task: ISimplificationTask): void;
  57617. private getSimplifier;
  57618. }
  57619. /**
  57620. * The implemented types of simplification
  57621. * At the moment only Quadratic Error Decimation is implemented
  57622. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57623. */
  57624. export enum SimplificationType {
  57625. /** Quadratic error decimation */
  57626. QUADRATIC = 0
  57627. }
  57628. }
  57629. declare module BABYLON {
  57630. interface Scene {
  57631. /** @hidden (Backing field) */
  57632. _simplificationQueue: SimplificationQueue;
  57633. /**
  57634. * Gets or sets the simplification queue attached to the scene
  57635. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57636. */
  57637. simplificationQueue: SimplificationQueue;
  57638. }
  57639. interface Mesh {
  57640. /**
  57641. * Simplify the mesh according to the given array of settings.
  57642. * Function will return immediately and will simplify async
  57643. * @param settings a collection of simplification settings
  57644. * @param parallelProcessing should all levels calculate parallel or one after the other
  57645. * @param simplificationType the type of simplification to run
  57646. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57647. * @returns the current mesh
  57648. */
  57649. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57650. }
  57651. /**
  57652. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57653. * created in a scene
  57654. */
  57655. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57656. /**
  57657. * The component name helpfull to identify the component in the list of scene components.
  57658. */
  57659. readonly name: string;
  57660. /**
  57661. * The scene the component belongs to.
  57662. */
  57663. scene: Scene;
  57664. /**
  57665. * Creates a new instance of the component for the given scene
  57666. * @param scene Defines the scene to register the component in
  57667. */
  57668. constructor(scene: Scene);
  57669. /**
  57670. * Registers the component in a given scene
  57671. */
  57672. register(): void;
  57673. /**
  57674. * Rebuilds the elements related to this component in case of
  57675. * context lost for instance.
  57676. */
  57677. rebuild(): void;
  57678. /**
  57679. * Disposes the component and the associated ressources
  57680. */
  57681. dispose(): void;
  57682. private _beforeCameraUpdate;
  57683. }
  57684. }
  57685. declare module BABYLON {
  57686. /**
  57687. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57688. */
  57689. export interface INavigationEnginePlugin {
  57690. /**
  57691. * plugin name
  57692. */
  57693. name: string;
  57694. /**
  57695. * Creates a navigation mesh
  57696. * @param meshes array of all the geometry used to compute the navigatio mesh
  57697. * @param parameters bunch of parameters used to filter geometry
  57698. */
  57699. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57700. /**
  57701. * Create a navigation mesh debug mesh
  57702. * @param scene is where the mesh will be added
  57703. * @returns debug display mesh
  57704. */
  57705. createDebugNavMesh(scene: Scene): Mesh;
  57706. /**
  57707. * Get a navigation mesh constrained position, closest to the parameter position
  57708. * @param position world position
  57709. * @returns the closest point to position constrained by the navigation mesh
  57710. */
  57711. getClosestPoint(position: Vector3): Vector3;
  57712. /**
  57713. * Get a navigation mesh constrained position, within a particular radius
  57714. * @param position world position
  57715. * @param maxRadius the maximum distance to the constrained world position
  57716. * @returns the closest point to position constrained by the navigation mesh
  57717. */
  57718. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57719. /**
  57720. * Compute the final position from a segment made of destination-position
  57721. * @param position world position
  57722. * @param destination world position
  57723. * @returns the resulting point along the navmesh
  57724. */
  57725. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57726. /**
  57727. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57728. * @param start world position
  57729. * @param end world position
  57730. * @returns array containing world position composing the path
  57731. */
  57732. computePath(start: Vector3, end: Vector3): Vector3[];
  57733. /**
  57734. * If this plugin is supported
  57735. * @returns true if plugin is supported
  57736. */
  57737. isSupported(): boolean;
  57738. /**
  57739. * Create a new Crowd so you can add agents
  57740. * @param maxAgents the maximum agent count in the crowd
  57741. * @param maxAgentRadius the maximum radius an agent can have
  57742. * @param scene to attach the crowd to
  57743. * @returns the crowd you can add agents to
  57744. */
  57745. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57746. /**
  57747. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57748. * The queries will try to find a solution within those bounds
  57749. * default is (1,1,1)
  57750. * @param extent x,y,z value that define the extent around the queries point of reference
  57751. */
  57752. setDefaultQueryExtent(extent: Vector3): void;
  57753. /**
  57754. * Get the Bounding box extent specified by setDefaultQueryExtent
  57755. * @returns the box extent values
  57756. */
  57757. getDefaultQueryExtent(): Vector3;
  57758. /**
  57759. * Release all resources
  57760. */
  57761. dispose(): void;
  57762. }
  57763. /**
  57764. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57765. */
  57766. export interface ICrowd {
  57767. /**
  57768. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57769. * You can attach anything to that node. The node position is updated in the scene update tick.
  57770. * @param pos world position that will be constrained by the navigation mesh
  57771. * @param parameters agent parameters
  57772. * @param transform hooked to the agent that will be update by the scene
  57773. * @returns agent index
  57774. */
  57775. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57776. /**
  57777. * Returns the agent position in world space
  57778. * @param index agent index returned by addAgent
  57779. * @returns world space position
  57780. */
  57781. getAgentPosition(index: number): Vector3;
  57782. /**
  57783. * Gets the agent velocity in world space
  57784. * @param index agent index returned by addAgent
  57785. * @returns world space velocity
  57786. */
  57787. getAgentVelocity(index: number): Vector3;
  57788. /**
  57789. * remove a particular agent previously created
  57790. * @param index agent index returned by addAgent
  57791. */
  57792. removeAgent(index: number): void;
  57793. /**
  57794. * get the list of all agents attached to this crowd
  57795. * @returns list of agent indices
  57796. */
  57797. getAgents(): number[];
  57798. /**
  57799. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57800. * @param deltaTime in seconds
  57801. */
  57802. update(deltaTime: number): void;
  57803. /**
  57804. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57805. * @param index agent index returned by addAgent
  57806. * @param destination targeted world position
  57807. */
  57808. agentGoto(index: number, destination: Vector3): void;
  57809. /**
  57810. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57811. * The queries will try to find a solution within those bounds
  57812. * default is (1,1,1)
  57813. * @param extent x,y,z value that define the extent around the queries point of reference
  57814. */
  57815. setDefaultQueryExtent(extent: Vector3): void;
  57816. /**
  57817. * Get the Bounding box extent specified by setDefaultQueryExtent
  57818. * @returns the box extent values
  57819. */
  57820. getDefaultQueryExtent(): Vector3;
  57821. /**
  57822. * Release all resources
  57823. */
  57824. dispose(): void;
  57825. }
  57826. /**
  57827. * Configures an agent
  57828. */
  57829. export interface IAgentParameters {
  57830. /**
  57831. * Agent radius. [Limit: >= 0]
  57832. */
  57833. radius: number;
  57834. /**
  57835. * Agent height. [Limit: > 0]
  57836. */
  57837. height: number;
  57838. /**
  57839. * Maximum allowed acceleration. [Limit: >= 0]
  57840. */
  57841. maxAcceleration: number;
  57842. /**
  57843. * Maximum allowed speed. [Limit: >= 0]
  57844. */
  57845. maxSpeed: number;
  57846. /**
  57847. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57848. */
  57849. collisionQueryRange: number;
  57850. /**
  57851. * The path visibility optimization range. [Limit: > 0]
  57852. */
  57853. pathOptimizationRange: number;
  57854. /**
  57855. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57856. */
  57857. separationWeight: number;
  57858. }
  57859. /**
  57860. * Configures the navigation mesh creation
  57861. */
  57862. export interface INavMeshParameters {
  57863. /**
  57864. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57865. */
  57866. cs: number;
  57867. /**
  57868. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57869. */
  57870. ch: number;
  57871. /**
  57872. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57873. */
  57874. walkableSlopeAngle: number;
  57875. /**
  57876. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57877. * be considered walkable. [Limit: >= 3] [Units: vx]
  57878. */
  57879. walkableHeight: number;
  57880. /**
  57881. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57882. */
  57883. walkableClimb: number;
  57884. /**
  57885. * The distance to erode/shrink the walkable area of the heightfield away from
  57886. * obstructions. [Limit: >=0] [Units: vx]
  57887. */
  57888. walkableRadius: number;
  57889. /**
  57890. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57891. */
  57892. maxEdgeLen: number;
  57893. /**
  57894. * The maximum distance a simplfied contour's border edges should deviate
  57895. * the original raw contour. [Limit: >=0] [Units: vx]
  57896. */
  57897. maxSimplificationError: number;
  57898. /**
  57899. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57900. */
  57901. minRegionArea: number;
  57902. /**
  57903. * Any regions with a span count smaller than this value will, if possible,
  57904. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57905. */
  57906. mergeRegionArea: number;
  57907. /**
  57908. * The maximum number of vertices allowed for polygons generated during the
  57909. * contour to polygon conversion process. [Limit: >= 3]
  57910. */
  57911. maxVertsPerPoly: number;
  57912. /**
  57913. * Sets the sampling distance to use when generating the detail mesh.
  57914. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57915. */
  57916. detailSampleDist: number;
  57917. /**
  57918. * The maximum distance the detail mesh surface should deviate from heightfield
  57919. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57920. */
  57921. detailSampleMaxError: number;
  57922. }
  57923. }
  57924. declare module BABYLON {
  57925. /**
  57926. * RecastJS navigation plugin
  57927. */
  57928. export class RecastJSPlugin implements INavigationEnginePlugin {
  57929. /**
  57930. * Reference to the Recast library
  57931. */
  57932. bjsRECAST: any;
  57933. /**
  57934. * plugin name
  57935. */
  57936. name: string;
  57937. /**
  57938. * the first navmesh created. We might extend this to support multiple navmeshes
  57939. */
  57940. navMesh: any;
  57941. /**
  57942. * Initializes the recastJS plugin
  57943. * @param recastInjection can be used to inject your own recast reference
  57944. */
  57945. constructor(recastInjection?: any);
  57946. /**
  57947. * Creates a navigation mesh
  57948. * @param meshes array of all the geometry used to compute the navigatio mesh
  57949. * @param parameters bunch of parameters used to filter geometry
  57950. */
  57951. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57952. /**
  57953. * Create a navigation mesh debug mesh
  57954. * @param scene is where the mesh will be added
  57955. * @returns debug display mesh
  57956. */
  57957. createDebugNavMesh(scene: Scene): Mesh;
  57958. /**
  57959. * Get a navigation mesh constrained position, closest to the parameter position
  57960. * @param position world position
  57961. * @returns the closest point to position constrained by the navigation mesh
  57962. */
  57963. getClosestPoint(position: Vector3): Vector3;
  57964. /**
  57965. * Get a navigation mesh constrained position, within a particular radius
  57966. * @param position world position
  57967. * @param maxRadius the maximum distance to the constrained world position
  57968. * @returns the closest point to position constrained by the navigation mesh
  57969. */
  57970. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57971. /**
  57972. * Compute the final position from a segment made of destination-position
  57973. * @param position world position
  57974. * @param destination world position
  57975. * @returns the resulting point along the navmesh
  57976. */
  57977. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57978. /**
  57979. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57980. * @param start world position
  57981. * @param end world position
  57982. * @returns array containing world position composing the path
  57983. */
  57984. computePath(start: Vector3, end: Vector3): Vector3[];
  57985. /**
  57986. * Create a new Crowd so you can add agents
  57987. * @param maxAgents the maximum agent count in the crowd
  57988. * @param maxAgentRadius the maximum radius an agent can have
  57989. * @param scene to attach the crowd to
  57990. * @returns the crowd you can add agents to
  57991. */
  57992. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57993. /**
  57994. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57995. * The queries will try to find a solution within those bounds
  57996. * default is (1,1,1)
  57997. * @param extent x,y,z value that define the extent around the queries point of reference
  57998. */
  57999. setDefaultQueryExtent(extent: Vector3): void;
  58000. /**
  58001. * Get the Bounding box extent specified by setDefaultQueryExtent
  58002. * @returns the box extent values
  58003. */
  58004. getDefaultQueryExtent(): Vector3;
  58005. /**
  58006. * Disposes
  58007. */
  58008. dispose(): void;
  58009. /**
  58010. * If this plugin is supported
  58011. * @returns true if plugin is supported
  58012. */
  58013. isSupported(): boolean;
  58014. }
  58015. /**
  58016. * Recast detour crowd implementation
  58017. */
  58018. export class RecastJSCrowd implements ICrowd {
  58019. /**
  58020. * Recast/detour plugin
  58021. */
  58022. bjsRECASTPlugin: RecastJSPlugin;
  58023. /**
  58024. * Link to the detour crowd
  58025. */
  58026. recastCrowd: any;
  58027. /**
  58028. * One transform per agent
  58029. */
  58030. transforms: TransformNode[];
  58031. /**
  58032. * All agents created
  58033. */
  58034. agents: number[];
  58035. /**
  58036. * Link to the scene is kept to unregister the crowd from the scene
  58037. */
  58038. private _scene;
  58039. /**
  58040. * Observer for crowd updates
  58041. */
  58042. private _onBeforeAnimationsObserver;
  58043. /**
  58044. * Constructor
  58045. * @param plugin recastJS plugin
  58046. * @param maxAgents the maximum agent count in the crowd
  58047. * @param maxAgentRadius the maximum radius an agent can have
  58048. * @param scene to attach the crowd to
  58049. * @returns the crowd you can add agents to
  58050. */
  58051. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58052. /**
  58053. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58054. * You can attach anything to that node. The node position is updated in the scene update tick.
  58055. * @param pos world position that will be constrained by the navigation mesh
  58056. * @param parameters agent parameters
  58057. * @param transform hooked to the agent that will be update by the scene
  58058. * @returns agent index
  58059. */
  58060. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58061. /**
  58062. * Returns the agent position in world space
  58063. * @param index agent index returned by addAgent
  58064. * @returns world space position
  58065. */
  58066. getAgentPosition(index: number): Vector3;
  58067. /**
  58068. * Returns the agent velocity in world space
  58069. * @param index agent index returned by addAgent
  58070. * @returns world space velocity
  58071. */
  58072. getAgentVelocity(index: number): Vector3;
  58073. /**
  58074. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58075. * @param index agent index returned by addAgent
  58076. * @param destination targeted world position
  58077. */
  58078. agentGoto(index: number, destination: Vector3): void;
  58079. /**
  58080. * remove a particular agent previously created
  58081. * @param index agent index returned by addAgent
  58082. */
  58083. removeAgent(index: number): void;
  58084. /**
  58085. * get the list of all agents attached to this crowd
  58086. * @returns list of agent indices
  58087. */
  58088. getAgents(): number[];
  58089. /**
  58090. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58091. * @param deltaTime in seconds
  58092. */
  58093. update(deltaTime: number): void;
  58094. /**
  58095. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58096. * The queries will try to find a solution within those bounds
  58097. * default is (1,1,1)
  58098. * @param extent x,y,z value that define the extent around the queries point of reference
  58099. */
  58100. setDefaultQueryExtent(extent: Vector3): void;
  58101. /**
  58102. * Get the Bounding box extent specified by setDefaultQueryExtent
  58103. * @returns the box extent values
  58104. */
  58105. getDefaultQueryExtent(): Vector3;
  58106. /**
  58107. * Release all resources
  58108. */
  58109. dispose(): void;
  58110. }
  58111. }
  58112. declare module BABYLON {
  58113. /**
  58114. * Class used to enable access to IndexedDB
  58115. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58116. */
  58117. export class Database implements IOfflineProvider {
  58118. private _callbackManifestChecked;
  58119. private _currentSceneUrl;
  58120. private _db;
  58121. private _enableSceneOffline;
  58122. private _enableTexturesOffline;
  58123. private _manifestVersionFound;
  58124. private _mustUpdateRessources;
  58125. private _hasReachedQuota;
  58126. private _isSupported;
  58127. private _idbFactory;
  58128. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58129. private static IsUASupportingBlobStorage;
  58130. /**
  58131. * Gets a boolean indicating if Database storate is enabled (off by default)
  58132. */
  58133. static IDBStorageEnabled: boolean;
  58134. /**
  58135. * Gets a boolean indicating if scene must be saved in the database
  58136. */
  58137. readonly enableSceneOffline: boolean;
  58138. /**
  58139. * Gets a boolean indicating if textures must be saved in the database
  58140. */
  58141. readonly enableTexturesOffline: boolean;
  58142. /**
  58143. * Creates a new Database
  58144. * @param urlToScene defines the url to load the scene
  58145. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58146. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58147. */
  58148. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58149. private static _ParseURL;
  58150. private static _ReturnFullUrlLocation;
  58151. private _checkManifestFile;
  58152. /**
  58153. * Open the database and make it available
  58154. * @param successCallback defines the callback to call on success
  58155. * @param errorCallback defines the callback to call on error
  58156. */
  58157. open(successCallback: () => void, errorCallback: () => void): void;
  58158. /**
  58159. * Loads an image from the database
  58160. * @param url defines the url to load from
  58161. * @param image defines the target DOM image
  58162. */
  58163. loadImage(url: string, image: HTMLImageElement): void;
  58164. private _loadImageFromDBAsync;
  58165. private _saveImageIntoDBAsync;
  58166. private _checkVersionFromDB;
  58167. private _loadVersionFromDBAsync;
  58168. private _saveVersionIntoDBAsync;
  58169. /**
  58170. * Loads a file from database
  58171. * @param url defines the URL to load from
  58172. * @param sceneLoaded defines a callback to call on success
  58173. * @param progressCallBack defines a callback to call when progress changed
  58174. * @param errorCallback defines a callback to call on error
  58175. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58176. */
  58177. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58178. private _loadFileAsync;
  58179. private _saveFileAsync;
  58180. /**
  58181. * Validates if xhr data is correct
  58182. * @param xhr defines the request to validate
  58183. * @param dataType defines the expected data type
  58184. * @returns true if data is correct
  58185. */
  58186. private static _ValidateXHRData;
  58187. }
  58188. }
  58189. declare module BABYLON {
  58190. /** @hidden */
  58191. export var gpuUpdateParticlesPixelShader: {
  58192. name: string;
  58193. shader: string;
  58194. };
  58195. }
  58196. declare module BABYLON {
  58197. /** @hidden */
  58198. export var gpuUpdateParticlesVertexShader: {
  58199. name: string;
  58200. shader: string;
  58201. };
  58202. }
  58203. declare module BABYLON {
  58204. /** @hidden */
  58205. export var clipPlaneFragmentDeclaration2: {
  58206. name: string;
  58207. shader: string;
  58208. };
  58209. }
  58210. declare module BABYLON {
  58211. /** @hidden */
  58212. export var gpuRenderParticlesPixelShader: {
  58213. name: string;
  58214. shader: string;
  58215. };
  58216. }
  58217. declare module BABYLON {
  58218. /** @hidden */
  58219. export var clipPlaneVertexDeclaration2: {
  58220. name: string;
  58221. shader: string;
  58222. };
  58223. }
  58224. declare module BABYLON {
  58225. /** @hidden */
  58226. export var gpuRenderParticlesVertexShader: {
  58227. name: string;
  58228. shader: string;
  58229. };
  58230. }
  58231. declare module BABYLON {
  58232. /**
  58233. * This represents a GPU particle system in Babylon
  58234. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58235. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58236. */
  58237. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58238. /**
  58239. * The layer mask we are rendering the particles through.
  58240. */
  58241. layerMask: number;
  58242. private _capacity;
  58243. private _activeCount;
  58244. private _currentActiveCount;
  58245. private _accumulatedCount;
  58246. private _renderEffect;
  58247. private _updateEffect;
  58248. private _buffer0;
  58249. private _buffer1;
  58250. private _spriteBuffer;
  58251. private _updateVAO;
  58252. private _renderVAO;
  58253. private _targetIndex;
  58254. private _sourceBuffer;
  58255. private _targetBuffer;
  58256. private _engine;
  58257. private _currentRenderId;
  58258. private _started;
  58259. private _stopped;
  58260. private _timeDelta;
  58261. private _randomTexture;
  58262. private _randomTexture2;
  58263. private _attributesStrideSize;
  58264. private _updateEffectOptions;
  58265. private _randomTextureSize;
  58266. private _actualFrame;
  58267. private readonly _rawTextureWidth;
  58268. /**
  58269. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58270. */
  58271. static readonly IsSupported: boolean;
  58272. /**
  58273. * An event triggered when the system is disposed.
  58274. */
  58275. onDisposeObservable: Observable<GPUParticleSystem>;
  58276. /**
  58277. * Gets the maximum number of particles active at the same time.
  58278. * @returns The max number of active particles.
  58279. */
  58280. getCapacity(): number;
  58281. /**
  58282. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58283. * to override the particles.
  58284. */
  58285. forceDepthWrite: boolean;
  58286. /**
  58287. * Gets or set the number of active particles
  58288. */
  58289. activeParticleCount: number;
  58290. private _preWarmDone;
  58291. /**
  58292. * Is this system ready to be used/rendered
  58293. * @return true if the system is ready
  58294. */
  58295. isReady(): boolean;
  58296. /**
  58297. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58298. * @returns True if it has been started, otherwise false.
  58299. */
  58300. isStarted(): boolean;
  58301. /**
  58302. * Starts the particle system and begins to emit
  58303. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58304. */
  58305. start(delay?: number): void;
  58306. /**
  58307. * Stops the particle system.
  58308. */
  58309. stop(): void;
  58310. /**
  58311. * Remove all active particles
  58312. */
  58313. reset(): void;
  58314. /**
  58315. * Returns the string "GPUParticleSystem"
  58316. * @returns a string containing the class name
  58317. */
  58318. getClassName(): string;
  58319. private _colorGradientsTexture;
  58320. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58321. /**
  58322. * Adds a new color gradient
  58323. * @param gradient defines the gradient to use (between 0 and 1)
  58324. * @param color1 defines the color to affect to the specified gradient
  58325. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58326. * @returns the current particle system
  58327. */
  58328. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58329. /**
  58330. * Remove a specific color gradient
  58331. * @param gradient defines the gradient to remove
  58332. * @returns the current particle system
  58333. */
  58334. removeColorGradient(gradient: number): GPUParticleSystem;
  58335. private _angularSpeedGradientsTexture;
  58336. private _sizeGradientsTexture;
  58337. private _velocityGradientsTexture;
  58338. private _limitVelocityGradientsTexture;
  58339. private _dragGradientsTexture;
  58340. private _addFactorGradient;
  58341. /**
  58342. * Adds a new size gradient
  58343. * @param gradient defines the gradient to use (between 0 and 1)
  58344. * @param factor defines the size factor to affect to the specified gradient
  58345. * @returns the current particle system
  58346. */
  58347. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58348. /**
  58349. * Remove a specific size gradient
  58350. * @param gradient defines the gradient to remove
  58351. * @returns the current particle system
  58352. */
  58353. removeSizeGradient(gradient: number): GPUParticleSystem;
  58354. /**
  58355. * Adds a new angular speed gradient
  58356. * @param gradient defines the gradient to use (between 0 and 1)
  58357. * @param factor defines the angular speed to affect to the specified gradient
  58358. * @returns the current particle system
  58359. */
  58360. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58361. /**
  58362. * Remove a specific angular speed gradient
  58363. * @param gradient defines the gradient to remove
  58364. * @returns the current particle system
  58365. */
  58366. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58367. /**
  58368. * Adds a new velocity gradient
  58369. * @param gradient defines the gradient to use (between 0 and 1)
  58370. * @param factor defines the velocity to affect to the specified gradient
  58371. * @returns the current particle system
  58372. */
  58373. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58374. /**
  58375. * Remove a specific velocity gradient
  58376. * @param gradient defines the gradient to remove
  58377. * @returns the current particle system
  58378. */
  58379. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58380. /**
  58381. * Adds a new limit velocity gradient
  58382. * @param gradient defines the gradient to use (between 0 and 1)
  58383. * @param factor defines the limit velocity value to affect to the specified gradient
  58384. * @returns the current particle system
  58385. */
  58386. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58387. /**
  58388. * Remove a specific limit velocity gradient
  58389. * @param gradient defines the gradient to remove
  58390. * @returns the current particle system
  58391. */
  58392. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58393. /**
  58394. * Adds a new drag gradient
  58395. * @param gradient defines the gradient to use (between 0 and 1)
  58396. * @param factor defines the drag value to affect to the specified gradient
  58397. * @returns the current particle system
  58398. */
  58399. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58400. /**
  58401. * Remove a specific drag gradient
  58402. * @param gradient defines the gradient to remove
  58403. * @returns the current particle system
  58404. */
  58405. removeDragGradient(gradient: number): GPUParticleSystem;
  58406. /**
  58407. * Not supported by GPUParticleSystem
  58408. * @param gradient defines the gradient to use (between 0 and 1)
  58409. * @param factor defines the emit rate value to affect to the specified gradient
  58410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58411. * @returns the current particle system
  58412. */
  58413. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58414. /**
  58415. * Not supported by GPUParticleSystem
  58416. * @param gradient defines the gradient to remove
  58417. * @returns the current particle system
  58418. */
  58419. removeEmitRateGradient(gradient: number): IParticleSystem;
  58420. /**
  58421. * Not supported by GPUParticleSystem
  58422. * @param gradient defines the gradient to use (between 0 and 1)
  58423. * @param factor defines the start size value to affect to the specified gradient
  58424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58425. * @returns the current particle system
  58426. */
  58427. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58428. /**
  58429. * Not supported by GPUParticleSystem
  58430. * @param gradient defines the gradient to remove
  58431. * @returns the current particle system
  58432. */
  58433. removeStartSizeGradient(gradient: number): IParticleSystem;
  58434. /**
  58435. * Not supported by GPUParticleSystem
  58436. * @param gradient defines the gradient to use (between 0 and 1)
  58437. * @param min defines the color remap minimal range
  58438. * @param max defines the color remap maximal range
  58439. * @returns the current particle system
  58440. */
  58441. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58442. /**
  58443. * Not supported by GPUParticleSystem
  58444. * @param gradient defines the gradient to remove
  58445. * @returns the current particle system
  58446. */
  58447. removeColorRemapGradient(): IParticleSystem;
  58448. /**
  58449. * Not supported by GPUParticleSystem
  58450. * @param gradient defines the gradient to use (between 0 and 1)
  58451. * @param min defines the alpha remap minimal range
  58452. * @param max defines the alpha remap maximal range
  58453. * @returns the current particle system
  58454. */
  58455. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58456. /**
  58457. * Not supported by GPUParticleSystem
  58458. * @param gradient defines the gradient to remove
  58459. * @returns the current particle system
  58460. */
  58461. removeAlphaRemapGradient(): IParticleSystem;
  58462. /**
  58463. * Not supported by GPUParticleSystem
  58464. * @param gradient defines the gradient to use (between 0 and 1)
  58465. * @param color defines the color to affect to the specified gradient
  58466. * @returns the current particle system
  58467. */
  58468. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58469. /**
  58470. * Not supported by GPUParticleSystem
  58471. * @param gradient defines the gradient to remove
  58472. * @returns the current particle system
  58473. */
  58474. removeRampGradient(): IParticleSystem;
  58475. /**
  58476. * Not supported by GPUParticleSystem
  58477. * @returns the list of ramp gradients
  58478. */
  58479. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58480. /**
  58481. * Not supported by GPUParticleSystem
  58482. * Gets or sets a boolean indicating that ramp gradients must be used
  58483. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58484. */
  58485. useRampGradients: boolean;
  58486. /**
  58487. * Not supported by GPUParticleSystem
  58488. * @param gradient defines the gradient to use (between 0 and 1)
  58489. * @param factor defines the life time factor to affect to the specified gradient
  58490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58491. * @returns the current particle system
  58492. */
  58493. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58494. /**
  58495. * Not supported by GPUParticleSystem
  58496. * @param gradient defines the gradient to remove
  58497. * @returns the current particle system
  58498. */
  58499. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58500. /**
  58501. * Instantiates a GPU particle system.
  58502. * 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.
  58503. * @param name The name of the particle system
  58504. * @param options The options used to create the system
  58505. * @param scene The scene the particle system belongs to
  58506. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58507. */
  58508. constructor(name: string, options: Partial<{
  58509. capacity: number;
  58510. randomTextureSize: number;
  58511. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58512. protected _reset(): void;
  58513. private _createUpdateVAO;
  58514. private _createRenderVAO;
  58515. private _initialize;
  58516. /** @hidden */
  58517. _recreateUpdateEffect(): void;
  58518. /** @hidden */
  58519. _recreateRenderEffect(): void;
  58520. /**
  58521. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58522. * @param preWarm defines if we are in the pre-warmimg phase
  58523. */
  58524. animate(preWarm?: boolean): void;
  58525. private _createFactorGradientTexture;
  58526. private _createSizeGradientTexture;
  58527. private _createAngularSpeedGradientTexture;
  58528. private _createVelocityGradientTexture;
  58529. private _createLimitVelocityGradientTexture;
  58530. private _createDragGradientTexture;
  58531. private _createColorGradientTexture;
  58532. /**
  58533. * Renders the particle system in its current state
  58534. * @param preWarm defines if the system should only update the particles but not render them
  58535. * @returns the current number of particles
  58536. */
  58537. render(preWarm?: boolean): number;
  58538. /**
  58539. * Rebuilds the particle system
  58540. */
  58541. rebuild(): void;
  58542. private _releaseBuffers;
  58543. private _releaseVAOs;
  58544. /**
  58545. * Disposes the particle system and free the associated resources
  58546. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58547. */
  58548. dispose(disposeTexture?: boolean): void;
  58549. /**
  58550. * Clones the particle system.
  58551. * @param name The name of the cloned object
  58552. * @param newEmitter The new emitter to use
  58553. * @returns the cloned particle system
  58554. */
  58555. clone(name: string, newEmitter: any): GPUParticleSystem;
  58556. /**
  58557. * Serializes the particle system to a JSON object.
  58558. * @returns the JSON object
  58559. */
  58560. serialize(): any;
  58561. /**
  58562. * Parses a JSON object to create a GPU particle system.
  58563. * @param parsedParticleSystem The JSON object to parse
  58564. * @param scene The scene to create the particle system in
  58565. * @param rootUrl The root url to use to load external dependencies like texture
  58566. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58567. * @returns the parsed GPU particle system
  58568. */
  58569. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58570. }
  58571. }
  58572. declare module BABYLON {
  58573. /**
  58574. * Represents a set of particle systems working together to create a specific effect
  58575. */
  58576. export class ParticleSystemSet implements IDisposable {
  58577. /**
  58578. * Gets or sets base Assets URL
  58579. */
  58580. static BaseAssetsUrl: string;
  58581. private _emitterCreationOptions;
  58582. private _emitterNode;
  58583. /**
  58584. * Gets the particle system list
  58585. */
  58586. systems: IParticleSystem[];
  58587. /**
  58588. * Gets the emitter node used with this set
  58589. */
  58590. readonly emitterNode: Nullable<TransformNode>;
  58591. /**
  58592. * Creates a new emitter mesh as a sphere
  58593. * @param options defines the options used to create the sphere
  58594. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58595. * @param scene defines the hosting scene
  58596. */
  58597. setEmitterAsSphere(options: {
  58598. diameter: number;
  58599. segments: number;
  58600. color: Color3;
  58601. }, renderingGroupId: number, scene: Scene): void;
  58602. /**
  58603. * Starts all particle systems of the set
  58604. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58605. */
  58606. start(emitter?: AbstractMesh): void;
  58607. /**
  58608. * Release all associated resources
  58609. */
  58610. dispose(): void;
  58611. /**
  58612. * Serialize the set into a JSON compatible object
  58613. * @returns a JSON compatible representation of the set
  58614. */
  58615. serialize(): any;
  58616. /**
  58617. * Parse a new ParticleSystemSet from a serialized source
  58618. * @param data defines a JSON compatible representation of the set
  58619. * @param scene defines the hosting scene
  58620. * @param gpu defines if we want GPU particles or CPU particles
  58621. * @returns a new ParticleSystemSet
  58622. */
  58623. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58624. }
  58625. }
  58626. declare module BABYLON {
  58627. /**
  58628. * This class is made for on one-liner static method to help creating particle system set.
  58629. */
  58630. export class ParticleHelper {
  58631. /**
  58632. * Gets or sets base Assets URL
  58633. */
  58634. static BaseAssetsUrl: string;
  58635. /**
  58636. * Create a default particle system that you can tweak
  58637. * @param emitter defines the emitter to use
  58638. * @param capacity defines the system capacity (default is 500 particles)
  58639. * @param scene defines the hosting scene
  58640. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58641. * @returns the new Particle system
  58642. */
  58643. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58644. /**
  58645. * This is the main static method (one-liner) of this helper to create different particle systems
  58646. * @param type This string represents the type to the particle system to create
  58647. * @param scene The scene where the particle system should live
  58648. * @param gpu If the system will use gpu
  58649. * @returns the ParticleSystemSet created
  58650. */
  58651. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58652. /**
  58653. * Static function used to export a particle system to a ParticleSystemSet variable.
  58654. * Please note that the emitter shape is not exported
  58655. * @param systems defines the particle systems to export
  58656. * @returns the created particle system set
  58657. */
  58658. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58659. }
  58660. }
  58661. declare module BABYLON {
  58662. interface Engine {
  58663. /**
  58664. * Create an effect to use with particle systems.
  58665. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58666. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58667. * @param uniformsNames defines a list of attribute names
  58668. * @param samplers defines an array of string used to represent textures
  58669. * @param defines defines the string containing the defines to use to compile the shaders
  58670. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58671. * @param onCompiled defines a function to call when the effect creation is successful
  58672. * @param onError defines a function to call when the effect creation has failed
  58673. * @returns the new Effect
  58674. */
  58675. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58676. }
  58677. interface Mesh {
  58678. /**
  58679. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58680. * @returns an array of IParticleSystem
  58681. */
  58682. getEmittedParticleSystems(): IParticleSystem[];
  58683. /**
  58684. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58685. * @returns an array of IParticleSystem
  58686. */
  58687. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58688. }
  58689. /**
  58690. * @hidden
  58691. */
  58692. export var _IDoNeedToBeInTheBuild: number;
  58693. }
  58694. declare module BABYLON {
  58695. /** Defines the 4 color options */
  58696. export enum PointColor {
  58697. /** color value */
  58698. Color = 2,
  58699. /** uv value */
  58700. UV = 1,
  58701. /** random value */
  58702. Random = 0,
  58703. /** stated value */
  58704. Stated = 3
  58705. }
  58706. /**
  58707. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58708. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  58709. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58710. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58711. *
  58712. * Full documentation here : TO BE ENTERED
  58713. */
  58714. export class PointsCloudSystem implements IDisposable {
  58715. /**
  58716. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58717. * Example : var p = SPS.particles[i];
  58718. */
  58719. particles: CloudPoint[];
  58720. /**
  58721. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58722. */
  58723. nbParticles: number;
  58724. /**
  58725. * This a counter for your own usage. It's not set by any SPS functions.
  58726. */
  58727. counter: number;
  58728. /**
  58729. * The PCS name. This name is also given to the underlying mesh.
  58730. */
  58731. name: string;
  58732. /**
  58733. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58734. */
  58735. mesh: Mesh;
  58736. /**
  58737. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58738. * Please read :
  58739. */
  58740. vars: any;
  58741. /**
  58742. * @hidden
  58743. */
  58744. _size: number;
  58745. private _scene;
  58746. private _promises;
  58747. private _positions;
  58748. private _indices;
  58749. private _normals;
  58750. private _colors;
  58751. private _uvs;
  58752. private _indices32;
  58753. private _positions32;
  58754. private _colors32;
  58755. private _uvs32;
  58756. private _updatable;
  58757. private _isVisibilityBoxLocked;
  58758. private _alwaysVisible;
  58759. private _groups;
  58760. private _groupCounter;
  58761. private _computeParticleColor;
  58762. private _computeParticleTexture;
  58763. private _computeParticleRotation;
  58764. private _computeBoundingBox;
  58765. private _isReady;
  58766. /**
  58767. * Creates a PCS (Points Cloud System) object
  58768. * @param name (String) is the PCS name, this will be the underlying mesh name
  58769. * @param pointSize (number) is the size for each point
  58770. * @param scene (Scene) is the scene in which the PCS is added
  58771. * @param options defines the options of the PCS e.g.
  58772. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58773. */
  58774. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58775. updatable?: boolean;
  58776. });
  58777. /**
  58778. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58779. * If no points were added to the PCS, the returned mesh is just a single point.
  58780. * @returns a promise for the created mesh
  58781. */
  58782. buildMeshAsync(): Promise<Mesh>;
  58783. /**
  58784. * @hidden
  58785. */
  58786. private _buildMesh;
  58787. private _addParticle;
  58788. private _randomUnitVector;
  58789. private _getColorIndicesForCoord;
  58790. private _setPointsColorOrUV;
  58791. private _colorFromTexture;
  58792. private _calculateDensity;
  58793. /**
  58794. * Adds points to the PCS in random positions within a unit sphere
  58795. * @param nb (positive integer) the number of particles to be created from this model
  58796. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58797. * @returns the number of groups in the system
  58798. */
  58799. addPoints(nb: number, pointFunction?: any): number;
  58800. /**
  58801. * Adds points to the PCS from the surface of the model shape
  58802. * @param mesh is any Mesh object that will be used as a surface model for the points
  58803. * @param nb (positive integer) the number of particles to be created from this model
  58804. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58805. * @param color (color3) to be used when colorWith is stated
  58806. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58807. * @returns the number of groups in the system
  58808. */
  58809. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58810. /**
  58811. * Adds points to the PCS inside the model shape
  58812. * @param mesh is any Mesh object that will be used as a surface model for the points
  58813. * @param nb (positive integer) the number of particles to be created from this model
  58814. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58815. * @param color (color4) to be used when colorWith is stated
  58816. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58817. * @returns the number of groups in the system
  58818. */
  58819. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58820. /**
  58821. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58822. * This method calls `updateParticle()` for each particle of the SPS.
  58823. * For an animated SPS, it is usually called within the render loop.
  58824. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58825. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58826. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58827. * @returns the PCS.
  58828. */
  58829. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58830. /**
  58831. * Disposes the PCS.
  58832. */
  58833. dispose(): void;
  58834. /**
  58835. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58836. * doc :
  58837. * @returns the PCS.
  58838. */
  58839. refreshVisibleSize(): PointsCloudSystem;
  58840. /**
  58841. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58842. * @param size the size (float) of the visibility box
  58843. * note : this doesn't lock the PCS mesh bounding box.
  58844. * doc :
  58845. */
  58846. setVisibilityBox(size: number): void;
  58847. /**
  58848. * Gets whether the PCS is always visible or not
  58849. * doc :
  58850. */
  58851. /**
  58852. * Sets the PCS as always visible or not
  58853. * doc :
  58854. */
  58855. isAlwaysVisible: boolean;
  58856. /**
  58857. * Tells to `setParticles()` to compute the particle rotations or not
  58858. * Default value : false. The PCS is faster when it's set to false
  58859. * Note : particle rotations are only applied to parent particles
  58860. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58861. */
  58862. computeParticleRotation: boolean;
  58863. /**
  58864. * Tells to `setParticles()` to compute the particle colors or not.
  58865. * Default value : true. The PCS is faster when it's set to false.
  58866. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58867. */
  58868. /**
  58869. * Gets if `setParticles()` computes the particle colors or not.
  58870. * Default value : false. The PCS is faster when it's set to false.
  58871. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58872. */
  58873. computeParticleColor: boolean;
  58874. /**
  58875. * Gets if `setParticles()` computes the particle textures or not.
  58876. * Default value : false. The PCS is faster when it's set to false.
  58877. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58878. */
  58879. computeParticleTexture: boolean;
  58880. /**
  58881. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58882. */
  58883. /**
  58884. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58885. */
  58886. computeBoundingBox: boolean;
  58887. /**
  58888. * This function does nothing. It may be overwritten to set all the particle first values.
  58889. * The PCS doesn't call this function, you may have to call it by your own.
  58890. * doc :
  58891. */
  58892. initParticles(): void;
  58893. /**
  58894. * This function does nothing. It may be overwritten to recycle a particle
  58895. * The PCS doesn't call this function, you can to call it
  58896. * doc :
  58897. * @param particle The particle to recycle
  58898. * @returns the recycled particle
  58899. */
  58900. recycleParticle(particle: CloudPoint): CloudPoint;
  58901. /**
  58902. * Updates a particle : this function should be overwritten by the user.
  58903. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58904. * doc :
  58905. * @example : just set a particle position or velocity and recycle conditions
  58906. * @param particle The particle to update
  58907. * @returns the updated particle
  58908. */
  58909. updateParticle(particle: CloudPoint): CloudPoint;
  58910. /**
  58911. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58912. * This does nothing and may be overwritten by the user.
  58913. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58914. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58915. * @param update the boolean update value actually passed to setParticles()
  58916. */
  58917. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58918. /**
  58919. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58920. * This will be passed three parameters.
  58921. * This does nothing and may be overwritten by the user.
  58922. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58923. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58924. * @param update the boolean update value actually passed to setParticles()
  58925. */
  58926. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58927. }
  58928. }
  58929. declare module BABYLON {
  58930. /**
  58931. * Represents one particle of a points cloud system.
  58932. */
  58933. export class CloudPoint {
  58934. /**
  58935. * particle global index
  58936. */
  58937. idx: number;
  58938. /**
  58939. * The color of the particle
  58940. */
  58941. color: Nullable<Color4>;
  58942. /**
  58943. * The world space position of the particle.
  58944. */
  58945. position: Vector3;
  58946. /**
  58947. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58948. */
  58949. rotation: Vector3;
  58950. /**
  58951. * The world space rotation quaternion of the particle.
  58952. */
  58953. rotationQuaternion: Nullable<Quaternion>;
  58954. /**
  58955. * The uv of the particle.
  58956. */
  58957. uv: Nullable<Vector2>;
  58958. /**
  58959. * The current speed of the particle.
  58960. */
  58961. velocity: Vector3;
  58962. /**
  58963. * The pivot point in the particle local space.
  58964. */
  58965. pivot: Vector3;
  58966. /**
  58967. * Must the particle be translated from its pivot point in its local space ?
  58968. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58969. * Default : false
  58970. */
  58971. translateFromPivot: boolean;
  58972. /**
  58973. * Index of this particle in the global "positions" array (Internal use)
  58974. * @hidden
  58975. */
  58976. _pos: number;
  58977. /**
  58978. * @hidden Index of this particle in the global "indices" array (Internal use)
  58979. */
  58980. _ind: number;
  58981. /**
  58982. * Group this particle belongs to
  58983. */
  58984. _group: PointsGroup;
  58985. /**
  58986. * Group id of this particle
  58987. */
  58988. groupId: number;
  58989. /**
  58990. * Index of the particle in its group id (Internal use)
  58991. */
  58992. idxInGroup: number;
  58993. /**
  58994. * @hidden Particle BoundingInfo object (Internal use)
  58995. */
  58996. _boundingInfo: BoundingInfo;
  58997. /**
  58998. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58999. */
  59000. _pcs: PointsCloudSystem;
  59001. /**
  59002. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59003. */
  59004. _stillInvisible: boolean;
  59005. /**
  59006. * @hidden Last computed particle rotation matrix
  59007. */
  59008. _rotationMatrix: number[];
  59009. /**
  59010. * Parent particle Id, if any.
  59011. * Default null.
  59012. */
  59013. parentId: Nullable<number>;
  59014. /**
  59015. * @hidden Internal global position in the PCS.
  59016. */
  59017. _globalPosition: Vector3;
  59018. /**
  59019. * Creates a Point Cloud object.
  59020. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59021. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59022. * @param group (PointsGroup) is the group the particle belongs to
  59023. * @param groupId (integer) is the group identifier in the PCS.
  59024. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59025. * @param pcs defines the PCS it is associated to
  59026. */
  59027. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59028. /**
  59029. * get point size
  59030. */
  59031. /**
  59032. * Set point size
  59033. */
  59034. size: Vector3;
  59035. /**
  59036. * Legacy support, changed quaternion to rotationQuaternion
  59037. */
  59038. /**
  59039. * Legacy support, changed quaternion to rotationQuaternion
  59040. */
  59041. quaternion: Nullable<Quaternion>;
  59042. /**
  59043. * Returns a boolean. True if the particle intersects a mesh, else false
  59044. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59045. * @param target is the object (point or mesh) what the intersection is computed against
  59046. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59047. * @returns true if it intersects
  59048. */
  59049. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59050. /**
  59051. * get the rotation matrix of the particle
  59052. * @hidden
  59053. */
  59054. getRotationMatrix(m: Matrix): void;
  59055. }
  59056. /**
  59057. * Represents a group of points in a points cloud system
  59058. * * PCS internal tool, don't use it manually.
  59059. */
  59060. export class PointsGroup {
  59061. /**
  59062. * The group id
  59063. * @hidden
  59064. */
  59065. groupID: number;
  59066. /**
  59067. * image data for group (internal use)
  59068. * @hidden
  59069. */
  59070. _groupImageData: Nullable<ArrayBufferView>;
  59071. /**
  59072. * Image Width (internal use)
  59073. * @hidden
  59074. */
  59075. _groupImgWidth: number;
  59076. /**
  59077. * Image Height (internal use)
  59078. * @hidden
  59079. */
  59080. _groupImgHeight: number;
  59081. /**
  59082. * Custom position function (internal use)
  59083. * @hidden
  59084. */
  59085. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59086. /**
  59087. * density per facet for surface points
  59088. * @hidden
  59089. */
  59090. _groupDensity: number[];
  59091. /**
  59092. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59093. * PCS internal tool, don't use it manually.
  59094. * @hidden
  59095. */
  59096. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59097. }
  59098. }
  59099. declare module BABYLON {
  59100. interface Scene {
  59101. /** @hidden (Backing field) */
  59102. _physicsEngine: Nullable<IPhysicsEngine>;
  59103. /**
  59104. * Gets the current physics engine
  59105. * @returns a IPhysicsEngine or null if none attached
  59106. */
  59107. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59108. /**
  59109. * Enables physics to the current scene
  59110. * @param gravity defines the scene's gravity for the physics engine
  59111. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59112. * @return a boolean indicating if the physics engine was initialized
  59113. */
  59114. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59115. /**
  59116. * Disables and disposes the physics engine associated with the scene
  59117. */
  59118. disablePhysicsEngine(): void;
  59119. /**
  59120. * Gets a boolean indicating if there is an active physics engine
  59121. * @returns a boolean indicating if there is an active physics engine
  59122. */
  59123. isPhysicsEnabled(): boolean;
  59124. /**
  59125. * Deletes a physics compound impostor
  59126. * @param compound defines the compound to delete
  59127. */
  59128. deleteCompoundImpostor(compound: any): void;
  59129. /**
  59130. * An event triggered when physic simulation is about to be run
  59131. */
  59132. onBeforePhysicsObservable: Observable<Scene>;
  59133. /**
  59134. * An event triggered when physic simulation has been done
  59135. */
  59136. onAfterPhysicsObservable: Observable<Scene>;
  59137. }
  59138. interface AbstractMesh {
  59139. /** @hidden */
  59140. _physicsImpostor: Nullable<PhysicsImpostor>;
  59141. /**
  59142. * Gets or sets impostor used for physic simulation
  59143. * @see http://doc.babylonjs.com/features/physics_engine
  59144. */
  59145. physicsImpostor: Nullable<PhysicsImpostor>;
  59146. /**
  59147. * Gets the current physics impostor
  59148. * @see http://doc.babylonjs.com/features/physics_engine
  59149. * @returns a physics impostor or null
  59150. */
  59151. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59152. /** Apply a physic impulse to the mesh
  59153. * @param force defines the force to apply
  59154. * @param contactPoint defines where to apply the force
  59155. * @returns the current mesh
  59156. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59157. */
  59158. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59159. /**
  59160. * Creates a physic joint between two meshes
  59161. * @param otherMesh defines the other mesh to use
  59162. * @param pivot1 defines the pivot to use on this mesh
  59163. * @param pivot2 defines the pivot to use on the other mesh
  59164. * @param options defines additional options (can be plugin dependent)
  59165. * @returns the current mesh
  59166. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59167. */
  59168. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59169. /** @hidden */
  59170. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59171. }
  59172. /**
  59173. * Defines the physics engine scene component responsible to manage a physics engine
  59174. */
  59175. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59176. /**
  59177. * The component name helpful to identify the component in the list of scene components.
  59178. */
  59179. readonly name: string;
  59180. /**
  59181. * The scene the component belongs to.
  59182. */
  59183. scene: Scene;
  59184. /**
  59185. * Creates a new instance of the component for the given scene
  59186. * @param scene Defines the scene to register the component in
  59187. */
  59188. constructor(scene: Scene);
  59189. /**
  59190. * Registers the component in a given scene
  59191. */
  59192. register(): void;
  59193. /**
  59194. * Rebuilds the elements related to this component in case of
  59195. * context lost for instance.
  59196. */
  59197. rebuild(): void;
  59198. /**
  59199. * Disposes the component and the associated ressources
  59200. */
  59201. dispose(): void;
  59202. }
  59203. }
  59204. declare module BABYLON {
  59205. /**
  59206. * A helper for physics simulations
  59207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59208. */
  59209. export class PhysicsHelper {
  59210. private _scene;
  59211. private _physicsEngine;
  59212. /**
  59213. * Initializes the Physics helper
  59214. * @param scene Babylon.js scene
  59215. */
  59216. constructor(scene: Scene);
  59217. /**
  59218. * Applies a radial explosion impulse
  59219. * @param origin the origin of the explosion
  59220. * @param radiusOrEventOptions the radius or the options of radial explosion
  59221. * @param strength the explosion strength
  59222. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59223. * @returns A physics radial explosion event, or null
  59224. */
  59225. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59226. /**
  59227. * Applies a radial explosion force
  59228. * @param origin the origin of the explosion
  59229. * @param radiusOrEventOptions the radius or the options of radial explosion
  59230. * @param strength the explosion strength
  59231. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59232. * @returns A physics radial explosion event, or null
  59233. */
  59234. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59235. /**
  59236. * Creates a gravitational field
  59237. * @param origin the origin of the explosion
  59238. * @param radiusOrEventOptions the radius or the options of radial explosion
  59239. * @param strength the explosion strength
  59240. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59241. * @returns A physics gravitational field event, or null
  59242. */
  59243. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59244. /**
  59245. * Creates a physics updraft event
  59246. * @param origin the origin of the updraft
  59247. * @param radiusOrEventOptions the radius or the options of the updraft
  59248. * @param strength the strength of the updraft
  59249. * @param height the height of the updraft
  59250. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59251. * @returns A physics updraft event, or null
  59252. */
  59253. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59254. /**
  59255. * Creates a physics vortex event
  59256. * @param origin the of the vortex
  59257. * @param radiusOrEventOptions the radius or the options of the vortex
  59258. * @param strength the strength of the vortex
  59259. * @param height the height of the vortex
  59260. * @returns a Physics vortex event, or null
  59261. * A physics vortex event or null
  59262. */
  59263. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59264. }
  59265. /**
  59266. * Represents a physics radial explosion event
  59267. */
  59268. class PhysicsRadialExplosionEvent {
  59269. private _scene;
  59270. private _options;
  59271. private _sphere;
  59272. private _dataFetched;
  59273. /**
  59274. * Initializes a radial explosioin event
  59275. * @param _scene BabylonJS scene
  59276. * @param _options The options for the vortex event
  59277. */
  59278. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59279. /**
  59280. * Returns the data related to the radial explosion event (sphere).
  59281. * @returns The radial explosion event data
  59282. */
  59283. getData(): PhysicsRadialExplosionEventData;
  59284. /**
  59285. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59286. * @param impostor A physics imposter
  59287. * @param origin the origin of the explosion
  59288. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59289. */
  59290. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59291. /**
  59292. * Triggers affecterd impostors callbacks
  59293. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59294. */
  59295. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59296. /**
  59297. * Disposes the sphere.
  59298. * @param force Specifies if the sphere should be disposed by force
  59299. */
  59300. dispose(force?: boolean): void;
  59301. /*** Helpers ***/
  59302. private _prepareSphere;
  59303. private _intersectsWithSphere;
  59304. }
  59305. /**
  59306. * Represents a gravitational field event
  59307. */
  59308. class PhysicsGravitationalFieldEvent {
  59309. private _physicsHelper;
  59310. private _scene;
  59311. private _origin;
  59312. private _options;
  59313. private _tickCallback;
  59314. private _sphere;
  59315. private _dataFetched;
  59316. /**
  59317. * Initializes the physics gravitational field event
  59318. * @param _physicsHelper A physics helper
  59319. * @param _scene BabylonJS scene
  59320. * @param _origin The origin position of the gravitational field event
  59321. * @param _options The options for the vortex event
  59322. */
  59323. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59324. /**
  59325. * Returns the data related to the gravitational field event (sphere).
  59326. * @returns A gravitational field event
  59327. */
  59328. getData(): PhysicsGravitationalFieldEventData;
  59329. /**
  59330. * Enables the gravitational field.
  59331. */
  59332. enable(): void;
  59333. /**
  59334. * Disables the gravitational field.
  59335. */
  59336. disable(): void;
  59337. /**
  59338. * Disposes the sphere.
  59339. * @param force The force to dispose from the gravitational field event
  59340. */
  59341. dispose(force?: boolean): void;
  59342. private _tick;
  59343. }
  59344. /**
  59345. * Represents a physics updraft event
  59346. */
  59347. class PhysicsUpdraftEvent {
  59348. private _scene;
  59349. private _origin;
  59350. private _options;
  59351. private _physicsEngine;
  59352. private _originTop;
  59353. private _originDirection;
  59354. private _tickCallback;
  59355. private _cylinder;
  59356. private _cylinderPosition;
  59357. private _dataFetched;
  59358. /**
  59359. * Initializes the physics updraft event
  59360. * @param _scene BabylonJS scene
  59361. * @param _origin The origin position of the updraft
  59362. * @param _options The options for the updraft event
  59363. */
  59364. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59365. /**
  59366. * Returns the data related to the updraft event (cylinder).
  59367. * @returns A physics updraft event
  59368. */
  59369. getData(): PhysicsUpdraftEventData;
  59370. /**
  59371. * Enables the updraft.
  59372. */
  59373. enable(): void;
  59374. /**
  59375. * Disables the updraft.
  59376. */
  59377. disable(): void;
  59378. /**
  59379. * Disposes the cylinder.
  59380. * @param force Specifies if the updraft should be disposed by force
  59381. */
  59382. dispose(force?: boolean): void;
  59383. private getImpostorHitData;
  59384. private _tick;
  59385. /*** Helpers ***/
  59386. private _prepareCylinder;
  59387. private _intersectsWithCylinder;
  59388. }
  59389. /**
  59390. * Represents a physics vortex event
  59391. */
  59392. class PhysicsVortexEvent {
  59393. private _scene;
  59394. private _origin;
  59395. private _options;
  59396. private _physicsEngine;
  59397. private _originTop;
  59398. private _tickCallback;
  59399. private _cylinder;
  59400. private _cylinderPosition;
  59401. private _dataFetched;
  59402. /**
  59403. * Initializes the physics vortex event
  59404. * @param _scene The BabylonJS scene
  59405. * @param _origin The origin position of the vortex
  59406. * @param _options The options for the vortex event
  59407. */
  59408. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59409. /**
  59410. * Returns the data related to the vortex event (cylinder).
  59411. * @returns The physics vortex event data
  59412. */
  59413. getData(): PhysicsVortexEventData;
  59414. /**
  59415. * Enables the vortex.
  59416. */
  59417. enable(): void;
  59418. /**
  59419. * Disables the cortex.
  59420. */
  59421. disable(): void;
  59422. /**
  59423. * Disposes the sphere.
  59424. * @param force
  59425. */
  59426. dispose(force?: boolean): void;
  59427. private getImpostorHitData;
  59428. private _tick;
  59429. /*** Helpers ***/
  59430. private _prepareCylinder;
  59431. private _intersectsWithCylinder;
  59432. }
  59433. /**
  59434. * Options fot the radial explosion event
  59435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59436. */
  59437. export class PhysicsRadialExplosionEventOptions {
  59438. /**
  59439. * The radius of the sphere for the radial explosion.
  59440. */
  59441. radius: number;
  59442. /**
  59443. * The strenth of the explosion.
  59444. */
  59445. strength: number;
  59446. /**
  59447. * The strenght of the force in correspondence to the distance of the affected object
  59448. */
  59449. falloff: PhysicsRadialImpulseFalloff;
  59450. /**
  59451. * Sphere options for the radial explosion.
  59452. */
  59453. sphere: {
  59454. segments: number;
  59455. diameter: number;
  59456. };
  59457. /**
  59458. * Sphere options for the radial explosion.
  59459. */
  59460. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59461. }
  59462. /**
  59463. * Options fot the updraft event
  59464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59465. */
  59466. export class PhysicsUpdraftEventOptions {
  59467. /**
  59468. * The radius of the cylinder for the vortex
  59469. */
  59470. radius: number;
  59471. /**
  59472. * The strenth of the updraft.
  59473. */
  59474. strength: number;
  59475. /**
  59476. * The height of the cylinder for the updraft.
  59477. */
  59478. height: number;
  59479. /**
  59480. * The mode for the the updraft.
  59481. */
  59482. updraftMode: PhysicsUpdraftMode;
  59483. }
  59484. /**
  59485. * Options fot the vortex event
  59486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59487. */
  59488. export class PhysicsVortexEventOptions {
  59489. /**
  59490. * The radius of the cylinder for the vortex
  59491. */
  59492. radius: number;
  59493. /**
  59494. * The strenth of the vortex.
  59495. */
  59496. strength: number;
  59497. /**
  59498. * The height of the cylinder for the vortex.
  59499. */
  59500. height: number;
  59501. /**
  59502. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59503. */
  59504. centripetalForceThreshold: number;
  59505. /**
  59506. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59507. */
  59508. centripetalForceMultiplier: number;
  59509. /**
  59510. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59511. */
  59512. centrifugalForceMultiplier: number;
  59513. /**
  59514. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59515. */
  59516. updraftForceMultiplier: number;
  59517. }
  59518. /**
  59519. * The strenght of the force in correspondence to the distance of the affected object
  59520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59521. */
  59522. export enum PhysicsRadialImpulseFalloff {
  59523. /** Defines that impulse is constant in strength across it's whole radius */
  59524. Constant = 0,
  59525. /** Defines that impulse gets weaker if it's further from the origin */
  59526. Linear = 1
  59527. }
  59528. /**
  59529. * The strength of the force in correspondence to the distance of the affected object
  59530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59531. */
  59532. export enum PhysicsUpdraftMode {
  59533. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59534. Center = 0,
  59535. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59536. Perpendicular = 1
  59537. }
  59538. /**
  59539. * Interface for a physics hit data
  59540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59541. */
  59542. export interface PhysicsHitData {
  59543. /**
  59544. * The force applied at the contact point
  59545. */
  59546. force: Vector3;
  59547. /**
  59548. * The contact point
  59549. */
  59550. contactPoint: Vector3;
  59551. /**
  59552. * The distance from the origin to the contact point
  59553. */
  59554. distanceFromOrigin: number;
  59555. }
  59556. /**
  59557. * Interface for radial explosion event data
  59558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59559. */
  59560. export interface PhysicsRadialExplosionEventData {
  59561. /**
  59562. * A sphere used for the radial explosion event
  59563. */
  59564. sphere: Mesh;
  59565. }
  59566. /**
  59567. * Interface for gravitational field event data
  59568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59569. */
  59570. export interface PhysicsGravitationalFieldEventData {
  59571. /**
  59572. * A sphere mesh used for the gravitational field event
  59573. */
  59574. sphere: Mesh;
  59575. }
  59576. /**
  59577. * Interface for updraft event data
  59578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59579. */
  59580. export interface PhysicsUpdraftEventData {
  59581. /**
  59582. * A cylinder used for the updraft event
  59583. */
  59584. cylinder: Mesh;
  59585. }
  59586. /**
  59587. * Interface for vortex event data
  59588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59589. */
  59590. export interface PhysicsVortexEventData {
  59591. /**
  59592. * A cylinder used for the vortex event
  59593. */
  59594. cylinder: Mesh;
  59595. }
  59596. /**
  59597. * Interface for an affected physics impostor
  59598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59599. */
  59600. export interface PhysicsAffectedImpostorWithData {
  59601. /**
  59602. * The impostor affected by the effect
  59603. */
  59604. impostor: PhysicsImpostor;
  59605. /**
  59606. * The data about the hit/horce from the explosion
  59607. */
  59608. hitData: PhysicsHitData;
  59609. }
  59610. }
  59611. declare module BABYLON {
  59612. /** @hidden */
  59613. export var blackAndWhitePixelShader: {
  59614. name: string;
  59615. shader: string;
  59616. };
  59617. }
  59618. declare module BABYLON {
  59619. /**
  59620. * Post process used to render in black and white
  59621. */
  59622. export class BlackAndWhitePostProcess extends PostProcess {
  59623. /**
  59624. * Linear about to convert he result to black and white (default: 1)
  59625. */
  59626. degree: number;
  59627. /**
  59628. * Creates a black and white post process
  59629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59630. * @param name The name of the effect.
  59631. * @param options The required width/height ratio to downsize to before computing the render pass.
  59632. * @param camera The camera to apply the render pass to.
  59633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59634. * @param engine The engine which the post process will be applied. (default: current engine)
  59635. * @param reusable If the post process can be reused on the same frame. (default: false)
  59636. */
  59637. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59638. }
  59639. }
  59640. declare module BABYLON {
  59641. /**
  59642. * This represents a set of one or more post processes in Babylon.
  59643. * A post process can be used to apply a shader to a texture after it is rendered.
  59644. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59645. */
  59646. export class PostProcessRenderEffect {
  59647. private _postProcesses;
  59648. private _getPostProcesses;
  59649. private _singleInstance;
  59650. private _cameras;
  59651. private _indicesForCamera;
  59652. /**
  59653. * Name of the effect
  59654. * @hidden
  59655. */
  59656. _name: string;
  59657. /**
  59658. * Instantiates a post process render effect.
  59659. * A post process can be used to apply a shader to a texture after it is rendered.
  59660. * @param engine The engine the effect is tied to
  59661. * @param name The name of the effect
  59662. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59663. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59664. */
  59665. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59666. /**
  59667. * Checks if all the post processes in the effect are supported.
  59668. */
  59669. readonly isSupported: boolean;
  59670. /**
  59671. * Updates the current state of the effect
  59672. * @hidden
  59673. */
  59674. _update(): void;
  59675. /**
  59676. * Attaches the effect on cameras
  59677. * @param cameras The camera to attach to.
  59678. * @hidden
  59679. */
  59680. _attachCameras(cameras: Camera): void;
  59681. /**
  59682. * Attaches the effect on cameras
  59683. * @param cameras The camera to attach to.
  59684. * @hidden
  59685. */
  59686. _attachCameras(cameras: Camera[]): void;
  59687. /**
  59688. * Detaches the effect on cameras
  59689. * @param cameras The camera to detatch from.
  59690. * @hidden
  59691. */
  59692. _detachCameras(cameras: Camera): void;
  59693. /**
  59694. * Detatches the effect on cameras
  59695. * @param cameras The camera to detatch from.
  59696. * @hidden
  59697. */
  59698. _detachCameras(cameras: Camera[]): void;
  59699. /**
  59700. * Enables the effect on given cameras
  59701. * @param cameras The camera to enable.
  59702. * @hidden
  59703. */
  59704. _enable(cameras: Camera): void;
  59705. /**
  59706. * Enables the effect on given cameras
  59707. * @param cameras The camera to enable.
  59708. * @hidden
  59709. */
  59710. _enable(cameras: Nullable<Camera[]>): void;
  59711. /**
  59712. * Disables the effect on the given cameras
  59713. * @param cameras The camera to disable.
  59714. * @hidden
  59715. */
  59716. _disable(cameras: Camera): void;
  59717. /**
  59718. * Disables the effect on the given cameras
  59719. * @param cameras The camera to disable.
  59720. * @hidden
  59721. */
  59722. _disable(cameras: Nullable<Camera[]>): void;
  59723. /**
  59724. * Gets a list of the post processes contained in the effect.
  59725. * @param camera The camera to get the post processes on.
  59726. * @returns The list of the post processes in the effect.
  59727. */
  59728. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59729. }
  59730. }
  59731. declare module BABYLON {
  59732. /** @hidden */
  59733. export var extractHighlightsPixelShader: {
  59734. name: string;
  59735. shader: string;
  59736. };
  59737. }
  59738. declare module BABYLON {
  59739. /**
  59740. * 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.
  59741. */
  59742. export class ExtractHighlightsPostProcess extends PostProcess {
  59743. /**
  59744. * The luminance threshold, pixels below this value will be set to black.
  59745. */
  59746. threshold: number;
  59747. /** @hidden */
  59748. _exposure: number;
  59749. /**
  59750. * Post process which has the input texture to be used when performing highlight extraction
  59751. * @hidden
  59752. */
  59753. _inputPostProcess: Nullable<PostProcess>;
  59754. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59755. }
  59756. }
  59757. declare module BABYLON {
  59758. /** @hidden */
  59759. export var bloomMergePixelShader: {
  59760. name: string;
  59761. shader: string;
  59762. };
  59763. }
  59764. declare module BABYLON {
  59765. /**
  59766. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59767. */
  59768. export class BloomMergePostProcess extends PostProcess {
  59769. /** Weight of the bloom to be added to the original input. */
  59770. weight: number;
  59771. /**
  59772. * Creates a new instance of @see BloomMergePostProcess
  59773. * @param name The name of the effect.
  59774. * @param originalFromInput Post process which's input will be used for the merge.
  59775. * @param blurred Blurred highlights post process which's output will be used.
  59776. * @param weight Weight of the bloom to be added to the original input.
  59777. * @param options The required width/height ratio to downsize to before computing the render pass.
  59778. * @param camera The camera to apply the render pass to.
  59779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59780. * @param engine The engine which the post process will be applied. (default: current engine)
  59781. * @param reusable If the post process can be reused on the same frame. (default: false)
  59782. * @param textureType Type of textures used when performing the post process. (default: 0)
  59783. * @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)
  59784. */
  59785. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59786. /** Weight of the bloom to be added to the original input. */
  59787. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59788. }
  59789. }
  59790. declare module BABYLON {
  59791. /**
  59792. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59793. */
  59794. export class BloomEffect extends PostProcessRenderEffect {
  59795. private bloomScale;
  59796. /**
  59797. * @hidden Internal
  59798. */
  59799. _effects: Array<PostProcess>;
  59800. /**
  59801. * @hidden Internal
  59802. */
  59803. _downscale: ExtractHighlightsPostProcess;
  59804. private _blurX;
  59805. private _blurY;
  59806. private _merge;
  59807. /**
  59808. * The luminance threshold to find bright areas of the image to bloom.
  59809. */
  59810. threshold: number;
  59811. /**
  59812. * The strength of the bloom.
  59813. */
  59814. weight: number;
  59815. /**
  59816. * Specifies the size of the bloom blur kernel, relative to the final output size
  59817. */
  59818. kernel: number;
  59819. /**
  59820. * Creates a new instance of @see BloomEffect
  59821. * @param scene The scene the effect belongs to.
  59822. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59823. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59824. * @param bloomWeight The the strength of bloom.
  59825. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59826. * @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)
  59827. */
  59828. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59829. /**
  59830. * Disposes each of the internal effects for a given camera.
  59831. * @param camera The camera to dispose the effect on.
  59832. */
  59833. disposeEffects(camera: Camera): void;
  59834. /**
  59835. * @hidden Internal
  59836. */
  59837. _updateEffects(): void;
  59838. /**
  59839. * Internal
  59840. * @returns if all the contained post processes are ready.
  59841. * @hidden
  59842. */
  59843. _isReady(): boolean;
  59844. }
  59845. }
  59846. declare module BABYLON {
  59847. /** @hidden */
  59848. export var chromaticAberrationPixelShader: {
  59849. name: string;
  59850. shader: string;
  59851. };
  59852. }
  59853. declare module BABYLON {
  59854. /**
  59855. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59856. */
  59857. export class ChromaticAberrationPostProcess extends PostProcess {
  59858. /**
  59859. * The amount of seperation of rgb channels (default: 30)
  59860. */
  59861. aberrationAmount: number;
  59862. /**
  59863. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59864. */
  59865. radialIntensity: number;
  59866. /**
  59867. * 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))
  59868. */
  59869. direction: Vector2;
  59870. /**
  59871. * 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))
  59872. */
  59873. centerPosition: Vector2;
  59874. /**
  59875. * Creates a new instance ChromaticAberrationPostProcess
  59876. * @param name The name of the effect.
  59877. * @param screenWidth The width of the screen to apply the effect on.
  59878. * @param screenHeight The height of the screen to apply the effect on.
  59879. * @param options The required width/height ratio to downsize to before computing the render pass.
  59880. * @param camera The camera to apply the render pass to.
  59881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59882. * @param engine The engine which the post process will be applied. (default: current engine)
  59883. * @param reusable If the post process can be reused on the same frame. (default: false)
  59884. * @param textureType Type of textures used when performing the post process. (default: 0)
  59885. * @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)
  59886. */
  59887. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59888. }
  59889. }
  59890. declare module BABYLON {
  59891. /** @hidden */
  59892. export var circleOfConfusionPixelShader: {
  59893. name: string;
  59894. shader: string;
  59895. };
  59896. }
  59897. declare module BABYLON {
  59898. /**
  59899. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59900. */
  59901. export class CircleOfConfusionPostProcess extends PostProcess {
  59902. /**
  59903. * 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.
  59904. */
  59905. lensSize: number;
  59906. /**
  59907. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59908. */
  59909. fStop: number;
  59910. /**
  59911. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59912. */
  59913. focusDistance: number;
  59914. /**
  59915. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59916. */
  59917. focalLength: number;
  59918. private _depthTexture;
  59919. /**
  59920. * Creates a new instance CircleOfConfusionPostProcess
  59921. * @param name The name of the effect.
  59922. * @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.
  59923. * @param options The required width/height ratio to downsize to before computing the render pass.
  59924. * @param camera The camera to apply the render pass to.
  59925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59926. * @param engine The engine which the post process will be applied. (default: current engine)
  59927. * @param reusable If the post process can be reused on the same frame. (default: false)
  59928. * @param textureType Type of textures used when performing the post process. (default: 0)
  59929. * @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)
  59930. */
  59931. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59932. /**
  59933. * 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.
  59934. */
  59935. depthTexture: RenderTargetTexture;
  59936. }
  59937. }
  59938. declare module BABYLON {
  59939. /** @hidden */
  59940. export var colorCorrectionPixelShader: {
  59941. name: string;
  59942. shader: string;
  59943. };
  59944. }
  59945. declare module BABYLON {
  59946. /**
  59947. *
  59948. * This post-process allows the modification of rendered colors by using
  59949. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59950. *
  59951. * The object needs to be provided an url to a texture containing the color
  59952. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59953. * Use an image editing software to tweak the LUT to match your needs.
  59954. *
  59955. * For an example of a color LUT, see here:
  59956. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59957. * For explanations on color grading, see here:
  59958. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59959. *
  59960. */
  59961. export class ColorCorrectionPostProcess extends PostProcess {
  59962. private _colorTableTexture;
  59963. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59964. }
  59965. }
  59966. declare module BABYLON {
  59967. /** @hidden */
  59968. export var convolutionPixelShader: {
  59969. name: string;
  59970. shader: string;
  59971. };
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59976. * input texture to perform effects such as edge detection or sharpening
  59977. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59978. */
  59979. export class ConvolutionPostProcess extends PostProcess {
  59980. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59981. kernel: number[];
  59982. /**
  59983. * Creates a new instance ConvolutionPostProcess
  59984. * @param name The name of the effect.
  59985. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59986. * @param options The required width/height ratio to downsize to before computing the render pass.
  59987. * @param camera The camera to apply the render pass to.
  59988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59989. * @param engine The engine which the post process will be applied. (default: current engine)
  59990. * @param reusable If the post process can be reused on the same frame. (default: false)
  59991. * @param textureType Type of textures used when performing the post process. (default: 0)
  59992. */
  59993. constructor(name: string,
  59994. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59995. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59996. /**
  59997. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59998. */
  59999. static EdgeDetect0Kernel: number[];
  60000. /**
  60001. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60002. */
  60003. static EdgeDetect1Kernel: number[];
  60004. /**
  60005. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60006. */
  60007. static EdgeDetect2Kernel: number[];
  60008. /**
  60009. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60010. */
  60011. static SharpenKernel: number[];
  60012. /**
  60013. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60014. */
  60015. static EmbossKernel: number[];
  60016. /**
  60017. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60018. */
  60019. static GaussianKernel: number[];
  60020. }
  60021. }
  60022. declare module BABYLON {
  60023. /**
  60024. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60025. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60026. * based on samples that have a large difference in distance than the center pixel.
  60027. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60028. */
  60029. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60030. direction: Vector2;
  60031. /**
  60032. * Creates a new instance CircleOfConfusionPostProcess
  60033. * @param name The name of the effect.
  60034. * @param scene The scene the effect belongs to.
  60035. * @param direction The direction the blur should be applied.
  60036. * @param kernel The size of the kernel used to blur.
  60037. * @param options The required width/height ratio to downsize to before computing the render pass.
  60038. * @param camera The camera to apply the render pass to.
  60039. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60040. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60042. * @param engine The engine which the post process will be applied. (default: current engine)
  60043. * @param reusable If the post process can be reused on the same frame. (default: false)
  60044. * @param textureType Type of textures used when performing the post process. (default: 0)
  60045. * @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)
  60046. */
  60047. 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);
  60048. }
  60049. }
  60050. declare module BABYLON {
  60051. /** @hidden */
  60052. export var depthOfFieldMergePixelShader: {
  60053. name: string;
  60054. shader: string;
  60055. };
  60056. }
  60057. declare module BABYLON {
  60058. /**
  60059. * Options to be set when merging outputs from the default pipeline.
  60060. */
  60061. export class DepthOfFieldMergePostProcessOptions {
  60062. /**
  60063. * The original image to merge on top of
  60064. */
  60065. originalFromInput: PostProcess;
  60066. /**
  60067. * Parameters to perform the merge of the depth of field effect
  60068. */
  60069. depthOfField?: {
  60070. circleOfConfusion: PostProcess;
  60071. blurSteps: Array<PostProcess>;
  60072. };
  60073. /**
  60074. * Parameters to perform the merge of bloom effect
  60075. */
  60076. bloom?: {
  60077. blurred: PostProcess;
  60078. weight: number;
  60079. };
  60080. }
  60081. /**
  60082. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60083. */
  60084. export class DepthOfFieldMergePostProcess extends PostProcess {
  60085. private blurSteps;
  60086. /**
  60087. * Creates a new instance of DepthOfFieldMergePostProcess
  60088. * @param name The name of the effect.
  60089. * @param originalFromInput Post process which's input will be used for the merge.
  60090. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60091. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60092. * @param options The required width/height ratio to downsize to before computing the render pass.
  60093. * @param camera The camera to apply the render pass to.
  60094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60095. * @param engine The engine which the post process will be applied. (default: current engine)
  60096. * @param reusable If the post process can be reused on the same frame. (default: false)
  60097. * @param textureType Type of textures used when performing the post process. (default: 0)
  60098. * @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)
  60099. */
  60100. 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);
  60101. /**
  60102. * Updates the effect with the current post process compile time values and recompiles the shader.
  60103. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60104. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60105. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60106. * @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
  60107. * @param onCompiled Called when the shader has been compiled.
  60108. * @param onError Called if there is an error when compiling a shader.
  60109. */
  60110. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60111. }
  60112. }
  60113. declare module BABYLON {
  60114. /**
  60115. * Specifies the level of max blur that should be applied when using the depth of field effect
  60116. */
  60117. export enum DepthOfFieldEffectBlurLevel {
  60118. /**
  60119. * Subtle blur
  60120. */
  60121. Low = 0,
  60122. /**
  60123. * Medium blur
  60124. */
  60125. Medium = 1,
  60126. /**
  60127. * Large blur
  60128. */
  60129. High = 2
  60130. }
  60131. /**
  60132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60133. */
  60134. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60135. private _circleOfConfusion;
  60136. /**
  60137. * @hidden Internal, blurs from high to low
  60138. */
  60139. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60140. private _depthOfFieldBlurY;
  60141. private _dofMerge;
  60142. /**
  60143. * @hidden Internal post processes in depth of field effect
  60144. */
  60145. _effects: Array<PostProcess>;
  60146. /**
  60147. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60148. */
  60149. focalLength: number;
  60150. /**
  60151. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60152. */
  60153. fStop: number;
  60154. /**
  60155. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60156. */
  60157. focusDistance: number;
  60158. /**
  60159. * 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.
  60160. */
  60161. lensSize: number;
  60162. /**
  60163. * Creates a new instance DepthOfFieldEffect
  60164. * @param scene The scene the effect belongs to.
  60165. * @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.
  60166. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60167. * @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)
  60168. */
  60169. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60170. /**
  60171. * Get the current class name of the current effet
  60172. * @returns "DepthOfFieldEffect"
  60173. */
  60174. getClassName(): string;
  60175. /**
  60176. * 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.
  60177. */
  60178. depthTexture: RenderTargetTexture;
  60179. /**
  60180. * Disposes each of the internal effects for a given camera.
  60181. * @param camera The camera to dispose the effect on.
  60182. */
  60183. disposeEffects(camera: Camera): void;
  60184. /**
  60185. * @hidden Internal
  60186. */
  60187. _updateEffects(): void;
  60188. /**
  60189. * Internal
  60190. * @returns if all the contained post processes are ready.
  60191. * @hidden
  60192. */
  60193. _isReady(): boolean;
  60194. }
  60195. }
  60196. declare module BABYLON {
  60197. /** @hidden */
  60198. export var displayPassPixelShader: {
  60199. name: string;
  60200. shader: string;
  60201. };
  60202. }
  60203. declare module BABYLON {
  60204. /**
  60205. * DisplayPassPostProcess which produces an output the same as it's input
  60206. */
  60207. export class DisplayPassPostProcess extends PostProcess {
  60208. /**
  60209. * Creates the DisplayPassPostProcess
  60210. * @param name The name of the effect.
  60211. * @param options The required width/height ratio to downsize to before computing the render pass.
  60212. * @param camera The camera to apply the render pass to.
  60213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60214. * @param engine The engine which the post process will be applied. (default: current engine)
  60215. * @param reusable If the post process can be reused on the same frame. (default: false)
  60216. */
  60217. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60218. }
  60219. }
  60220. declare module BABYLON {
  60221. /** @hidden */
  60222. export var filterPixelShader: {
  60223. name: string;
  60224. shader: string;
  60225. };
  60226. }
  60227. declare module BABYLON {
  60228. /**
  60229. * Applies a kernel filter to the image
  60230. */
  60231. export class FilterPostProcess extends PostProcess {
  60232. /** The matrix to be applied to the image */
  60233. kernelMatrix: Matrix;
  60234. /**
  60235. *
  60236. * @param name The name of the effect.
  60237. * @param kernelMatrix The matrix to be applied to the image
  60238. * @param options The required width/height ratio to downsize to before computing the render pass.
  60239. * @param camera The camera to apply the render pass to.
  60240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60241. * @param engine The engine which the post process will be applied. (default: current engine)
  60242. * @param reusable If the post process can be reused on the same frame. (default: false)
  60243. */
  60244. constructor(name: string,
  60245. /** The matrix to be applied to the image */
  60246. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60247. }
  60248. }
  60249. declare module BABYLON {
  60250. /** @hidden */
  60251. export var fxaaPixelShader: {
  60252. name: string;
  60253. shader: string;
  60254. };
  60255. }
  60256. declare module BABYLON {
  60257. /** @hidden */
  60258. export var fxaaVertexShader: {
  60259. name: string;
  60260. shader: string;
  60261. };
  60262. }
  60263. declare module BABYLON {
  60264. /**
  60265. * Fxaa post process
  60266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60267. */
  60268. export class FxaaPostProcess extends PostProcess {
  60269. /** @hidden */
  60270. texelWidth: number;
  60271. /** @hidden */
  60272. texelHeight: number;
  60273. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60274. private _getDefines;
  60275. }
  60276. }
  60277. declare module BABYLON {
  60278. /** @hidden */
  60279. export var grainPixelShader: {
  60280. name: string;
  60281. shader: string;
  60282. };
  60283. }
  60284. declare module BABYLON {
  60285. /**
  60286. * The GrainPostProcess adds noise to the image at mid luminance levels
  60287. */
  60288. export class GrainPostProcess extends PostProcess {
  60289. /**
  60290. * The intensity of the grain added (default: 30)
  60291. */
  60292. intensity: number;
  60293. /**
  60294. * If the grain should be randomized on every frame
  60295. */
  60296. animated: boolean;
  60297. /**
  60298. * Creates a new instance of @see GrainPostProcess
  60299. * @param name The name of the effect.
  60300. * @param options The required width/height ratio to downsize to before computing the render pass.
  60301. * @param camera The camera to apply the render pass to.
  60302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60303. * @param engine The engine which the post process will be applied. (default: current engine)
  60304. * @param reusable If the post process can be reused on the same frame. (default: false)
  60305. * @param textureType Type of textures used when performing the post process. (default: 0)
  60306. * @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)
  60307. */
  60308. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60309. }
  60310. }
  60311. declare module BABYLON {
  60312. /** @hidden */
  60313. export var highlightsPixelShader: {
  60314. name: string;
  60315. shader: string;
  60316. };
  60317. }
  60318. declare module BABYLON {
  60319. /**
  60320. * Extracts highlights from the image
  60321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60322. */
  60323. export class HighlightsPostProcess extends PostProcess {
  60324. /**
  60325. * Extracts highlights from the image
  60326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60327. * @param name The name of the effect.
  60328. * @param options The required width/height ratio to downsize to before computing the render pass.
  60329. * @param camera The camera to apply the render pass to.
  60330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60331. * @param engine The engine which the post process will be applied. (default: current engine)
  60332. * @param reusable If the post process can be reused on the same frame. (default: false)
  60333. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60334. */
  60335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60336. }
  60337. }
  60338. declare module BABYLON {
  60339. /** @hidden */
  60340. export var mrtFragmentDeclaration: {
  60341. name: string;
  60342. shader: string;
  60343. };
  60344. }
  60345. declare module BABYLON {
  60346. /** @hidden */
  60347. export var geometryPixelShader: {
  60348. name: string;
  60349. shader: string;
  60350. };
  60351. }
  60352. declare module BABYLON {
  60353. /** @hidden */
  60354. export var geometryVertexShader: {
  60355. name: string;
  60356. shader: string;
  60357. };
  60358. }
  60359. declare module BABYLON {
  60360. /** @hidden */
  60361. interface ISavedTransformationMatrix {
  60362. world: Matrix;
  60363. viewProjection: Matrix;
  60364. }
  60365. /**
  60366. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60367. */
  60368. export class GeometryBufferRenderer {
  60369. /**
  60370. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60371. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60372. */
  60373. static readonly POSITION_TEXTURE_TYPE: number;
  60374. /**
  60375. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60376. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60377. */
  60378. static readonly VELOCITY_TEXTURE_TYPE: number;
  60379. /**
  60380. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60381. * in order to compute objects velocities when enableVelocity is set to "true"
  60382. * @hidden
  60383. */
  60384. _previousTransformationMatrices: {
  60385. [index: number]: ISavedTransformationMatrix;
  60386. };
  60387. /**
  60388. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60389. * in order to compute objects velocities when enableVelocity is set to "true"
  60390. * @hidden
  60391. */
  60392. _previousBonesTransformationMatrices: {
  60393. [index: number]: Float32Array;
  60394. };
  60395. /**
  60396. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60397. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60398. */
  60399. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60400. private _scene;
  60401. private _multiRenderTarget;
  60402. private _ratio;
  60403. private _enablePosition;
  60404. private _enableVelocity;
  60405. private _positionIndex;
  60406. private _velocityIndex;
  60407. protected _effect: Effect;
  60408. protected _cachedDefines: string;
  60409. /**
  60410. * Set the render list (meshes to be rendered) used in the G buffer.
  60411. */
  60412. renderList: Mesh[];
  60413. /**
  60414. * Gets wether or not G buffer are supported by the running hardware.
  60415. * This requires draw buffer supports
  60416. */
  60417. readonly isSupported: boolean;
  60418. /**
  60419. * Returns the index of the given texture type in the G-Buffer textures array
  60420. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60421. * @returns the index of the given texture type in the G-Buffer textures array
  60422. */
  60423. getTextureIndex(textureType: number): number;
  60424. /**
  60425. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60426. */
  60427. /**
  60428. * Sets whether or not objects positions are enabled for the G buffer.
  60429. */
  60430. enablePosition: boolean;
  60431. /**
  60432. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60433. */
  60434. /**
  60435. * Sets wether or not objects velocities are enabled for the G buffer.
  60436. */
  60437. enableVelocity: boolean;
  60438. /**
  60439. * Gets the scene associated with the buffer.
  60440. */
  60441. readonly scene: Scene;
  60442. /**
  60443. * Gets the ratio used by the buffer during its creation.
  60444. * How big is the buffer related to the main canvas.
  60445. */
  60446. readonly ratio: number;
  60447. /** @hidden */
  60448. static _SceneComponentInitialization: (scene: Scene) => void;
  60449. /**
  60450. * Creates a new G Buffer for the scene
  60451. * @param scene The scene the buffer belongs to
  60452. * @param ratio How big is the buffer related to the main canvas.
  60453. */
  60454. constructor(scene: Scene, ratio?: number);
  60455. /**
  60456. * Checks wether everything is ready to render a submesh to the G buffer.
  60457. * @param subMesh the submesh to check readiness for
  60458. * @param useInstances is the mesh drawn using instance or not
  60459. * @returns true if ready otherwise false
  60460. */
  60461. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60462. /**
  60463. * Gets the current underlying G Buffer.
  60464. * @returns the buffer
  60465. */
  60466. getGBuffer(): MultiRenderTarget;
  60467. /**
  60468. * Gets the number of samples used to render the buffer (anti aliasing).
  60469. */
  60470. /**
  60471. * Sets the number of samples used to render the buffer (anti aliasing).
  60472. */
  60473. samples: number;
  60474. /**
  60475. * Disposes the renderer and frees up associated resources.
  60476. */
  60477. dispose(): void;
  60478. protected _createRenderTargets(): void;
  60479. private _copyBonesTransformationMatrices;
  60480. }
  60481. }
  60482. declare module BABYLON {
  60483. interface Scene {
  60484. /** @hidden (Backing field) */
  60485. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60486. /**
  60487. * Gets or Sets the current geometry buffer associated to the scene.
  60488. */
  60489. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60490. /**
  60491. * Enables a GeometryBufferRender and associates it with the scene
  60492. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60493. * @returns the GeometryBufferRenderer
  60494. */
  60495. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60496. /**
  60497. * Disables the GeometryBufferRender associated with the scene
  60498. */
  60499. disableGeometryBufferRenderer(): void;
  60500. }
  60501. /**
  60502. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60503. * in several rendering techniques.
  60504. */
  60505. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60506. /**
  60507. * The component name helpful to identify the component in the list of scene components.
  60508. */
  60509. readonly name: string;
  60510. /**
  60511. * The scene the component belongs to.
  60512. */
  60513. scene: Scene;
  60514. /**
  60515. * Creates a new instance of the component for the given scene
  60516. * @param scene Defines the scene to register the component in
  60517. */
  60518. constructor(scene: Scene);
  60519. /**
  60520. * Registers the component in a given scene
  60521. */
  60522. register(): void;
  60523. /**
  60524. * Rebuilds the elements related to this component in case of
  60525. * context lost for instance.
  60526. */
  60527. rebuild(): void;
  60528. /**
  60529. * Disposes the component and the associated ressources
  60530. */
  60531. dispose(): void;
  60532. private _gatherRenderTargets;
  60533. }
  60534. }
  60535. declare module BABYLON {
  60536. /** @hidden */
  60537. export var motionBlurPixelShader: {
  60538. name: string;
  60539. shader: string;
  60540. };
  60541. }
  60542. declare module BABYLON {
  60543. /**
  60544. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60545. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60546. * As an example, all you have to do is to create the post-process:
  60547. * var mb = new BABYLON.MotionBlurPostProcess(
  60548. * 'mb', // The name of the effect.
  60549. * scene, // The scene containing the objects to blur according to their velocity.
  60550. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60551. * camera // The camera to apply the render pass to.
  60552. * );
  60553. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60554. */
  60555. export class MotionBlurPostProcess extends PostProcess {
  60556. /**
  60557. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60558. */
  60559. motionStrength: number;
  60560. /**
  60561. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60562. */
  60563. /**
  60564. * Sets the number of iterations to be used for motion blur quality
  60565. */
  60566. motionBlurSamples: number;
  60567. private _motionBlurSamples;
  60568. private _geometryBufferRenderer;
  60569. /**
  60570. * Creates a new instance MotionBlurPostProcess
  60571. * @param name The name of the effect.
  60572. * @param scene The scene containing the objects to blur according to their velocity.
  60573. * @param options The required width/height ratio to downsize to before computing the render pass.
  60574. * @param camera The camera to apply the render pass to.
  60575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60576. * @param engine The engine which the post process will be applied. (default: current engine)
  60577. * @param reusable If the post process can be reused on the same frame. (default: false)
  60578. * @param textureType Type of textures used when performing the post process. (default: 0)
  60579. * @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)
  60580. */
  60581. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60582. /**
  60583. * Excludes the given skinned mesh from computing bones velocities.
  60584. * 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.
  60585. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60586. */
  60587. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60588. /**
  60589. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60590. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60591. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60592. */
  60593. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60594. /**
  60595. * Disposes the post process.
  60596. * @param camera The camera to dispose the post process on.
  60597. */
  60598. dispose(camera?: Camera): void;
  60599. }
  60600. }
  60601. declare module BABYLON {
  60602. /** @hidden */
  60603. export var refractionPixelShader: {
  60604. name: string;
  60605. shader: string;
  60606. };
  60607. }
  60608. declare module BABYLON {
  60609. /**
  60610. * Post process which applies a refractin texture
  60611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60612. */
  60613. export class RefractionPostProcess extends PostProcess {
  60614. /** the base color of the refraction (used to taint the rendering) */
  60615. color: Color3;
  60616. /** simulated refraction depth */
  60617. depth: number;
  60618. /** the coefficient of the base color (0 to remove base color tainting) */
  60619. colorLevel: number;
  60620. private _refTexture;
  60621. private _ownRefractionTexture;
  60622. /**
  60623. * Gets or sets the refraction texture
  60624. * Please note that you are responsible for disposing the texture if you set it manually
  60625. */
  60626. refractionTexture: Texture;
  60627. /**
  60628. * Initializes the RefractionPostProcess
  60629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60630. * @param name The name of the effect.
  60631. * @param refractionTextureUrl Url of the refraction texture to use
  60632. * @param color the base color of the refraction (used to taint the rendering)
  60633. * @param depth simulated refraction depth
  60634. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60635. * @param camera The camera to apply the render pass to.
  60636. * @param options The required width/height ratio to downsize to before computing the render pass.
  60637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60638. * @param engine The engine which the post process will be applied. (default: current engine)
  60639. * @param reusable If the post process can be reused on the same frame. (default: false)
  60640. */
  60641. constructor(name: string, refractionTextureUrl: string,
  60642. /** the base color of the refraction (used to taint the rendering) */
  60643. color: Color3,
  60644. /** simulated refraction depth */
  60645. depth: number,
  60646. /** the coefficient of the base color (0 to remove base color tainting) */
  60647. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60648. /**
  60649. * Disposes of the post process
  60650. * @param camera Camera to dispose post process on
  60651. */
  60652. dispose(camera: Camera): void;
  60653. }
  60654. }
  60655. declare module BABYLON {
  60656. /** @hidden */
  60657. export var sharpenPixelShader: {
  60658. name: string;
  60659. shader: string;
  60660. };
  60661. }
  60662. declare module BABYLON {
  60663. /**
  60664. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60665. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60666. */
  60667. export class SharpenPostProcess extends PostProcess {
  60668. /**
  60669. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60670. */
  60671. colorAmount: number;
  60672. /**
  60673. * How much sharpness should be applied (default: 0.3)
  60674. */
  60675. edgeAmount: number;
  60676. /**
  60677. * Creates a new instance ConvolutionPostProcess
  60678. * @param name The name of the effect.
  60679. * @param options The required width/height ratio to downsize to before computing the render pass.
  60680. * @param camera The camera to apply the render pass to.
  60681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60682. * @param engine The engine which the post process will be applied. (default: current engine)
  60683. * @param reusable If the post process can be reused on the same frame. (default: false)
  60684. * @param textureType Type of textures used when performing the post process. (default: 0)
  60685. * @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)
  60686. */
  60687. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60688. }
  60689. }
  60690. declare module BABYLON {
  60691. /**
  60692. * PostProcessRenderPipeline
  60693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60694. */
  60695. export class PostProcessRenderPipeline {
  60696. private engine;
  60697. private _renderEffects;
  60698. private _renderEffectsForIsolatedPass;
  60699. /**
  60700. * List of inspectable custom properties (used by the Inspector)
  60701. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60702. */
  60703. inspectableCustomProperties: IInspectable[];
  60704. /**
  60705. * @hidden
  60706. */
  60707. protected _cameras: Camera[];
  60708. /** @hidden */
  60709. _name: string;
  60710. /**
  60711. * Gets pipeline name
  60712. */
  60713. readonly name: string;
  60714. /** Gets the list of attached cameras */
  60715. readonly cameras: Camera[];
  60716. /**
  60717. * Initializes a PostProcessRenderPipeline
  60718. * @param engine engine to add the pipeline to
  60719. * @param name name of the pipeline
  60720. */
  60721. constructor(engine: Engine, name: string);
  60722. /**
  60723. * Gets the class name
  60724. * @returns "PostProcessRenderPipeline"
  60725. */
  60726. getClassName(): string;
  60727. /**
  60728. * If all the render effects in the pipeline are supported
  60729. */
  60730. readonly isSupported: boolean;
  60731. /**
  60732. * Adds an effect to the pipeline
  60733. * @param renderEffect the effect to add
  60734. */
  60735. addEffect(renderEffect: PostProcessRenderEffect): void;
  60736. /** @hidden */
  60737. _rebuild(): void;
  60738. /** @hidden */
  60739. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60740. /** @hidden */
  60741. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60742. /** @hidden */
  60743. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60744. /** @hidden */
  60745. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60746. /** @hidden */
  60747. _attachCameras(cameras: Camera, unique: boolean): void;
  60748. /** @hidden */
  60749. _attachCameras(cameras: Camera[], unique: boolean): void;
  60750. /** @hidden */
  60751. _detachCameras(cameras: Camera): void;
  60752. /** @hidden */
  60753. _detachCameras(cameras: Nullable<Camera[]>): void;
  60754. /** @hidden */
  60755. _update(): void;
  60756. /** @hidden */
  60757. _reset(): void;
  60758. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60759. /**
  60760. * Disposes of the pipeline
  60761. */
  60762. dispose(): void;
  60763. }
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * PostProcessRenderPipelineManager class
  60768. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60769. */
  60770. export class PostProcessRenderPipelineManager {
  60771. private _renderPipelines;
  60772. /**
  60773. * Initializes a PostProcessRenderPipelineManager
  60774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60775. */
  60776. constructor();
  60777. /**
  60778. * Gets the list of supported render pipelines
  60779. */
  60780. readonly supportedPipelines: PostProcessRenderPipeline[];
  60781. /**
  60782. * Adds a pipeline to the manager
  60783. * @param renderPipeline The pipeline to add
  60784. */
  60785. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60786. /**
  60787. * Attaches a camera to the pipeline
  60788. * @param renderPipelineName The name of the pipeline to attach to
  60789. * @param cameras the camera to attach
  60790. * @param unique if the camera can be attached multiple times to the pipeline
  60791. */
  60792. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60793. /**
  60794. * Detaches a camera from the pipeline
  60795. * @param renderPipelineName The name of the pipeline to detach from
  60796. * @param cameras the camera to detach
  60797. */
  60798. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60799. /**
  60800. * Enables an effect by name on a pipeline
  60801. * @param renderPipelineName the name of the pipeline to enable the effect in
  60802. * @param renderEffectName the name of the effect to enable
  60803. * @param cameras the cameras that the effect should be enabled on
  60804. */
  60805. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60806. /**
  60807. * Disables an effect by name on a pipeline
  60808. * @param renderPipelineName the name of the pipeline to disable the effect in
  60809. * @param renderEffectName the name of the effect to disable
  60810. * @param cameras the cameras that the effect should be disabled on
  60811. */
  60812. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60813. /**
  60814. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60815. */
  60816. update(): void;
  60817. /** @hidden */
  60818. _rebuild(): void;
  60819. /**
  60820. * Disposes of the manager and pipelines
  60821. */
  60822. dispose(): void;
  60823. }
  60824. }
  60825. declare module BABYLON {
  60826. interface Scene {
  60827. /** @hidden (Backing field) */
  60828. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60829. /**
  60830. * Gets the postprocess render pipeline manager
  60831. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60832. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60833. */
  60834. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60835. }
  60836. /**
  60837. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60838. */
  60839. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60840. /**
  60841. * The component name helpfull to identify the component in the list of scene components.
  60842. */
  60843. readonly name: string;
  60844. /**
  60845. * The scene the component belongs to.
  60846. */
  60847. scene: Scene;
  60848. /**
  60849. * Creates a new instance of the component for the given scene
  60850. * @param scene Defines the scene to register the component in
  60851. */
  60852. constructor(scene: Scene);
  60853. /**
  60854. * Registers the component in a given scene
  60855. */
  60856. register(): void;
  60857. /**
  60858. * Rebuilds the elements related to this component in case of
  60859. * context lost for instance.
  60860. */
  60861. rebuild(): void;
  60862. /**
  60863. * Disposes the component and the associated ressources
  60864. */
  60865. dispose(): void;
  60866. private _gatherRenderTargets;
  60867. }
  60868. }
  60869. declare module BABYLON {
  60870. /**
  60871. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60872. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60873. */
  60874. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60875. private _scene;
  60876. private _camerasToBeAttached;
  60877. /**
  60878. * ID of the sharpen post process,
  60879. */
  60880. private readonly SharpenPostProcessId;
  60881. /**
  60882. * @ignore
  60883. * ID of the image processing post process;
  60884. */
  60885. readonly ImageProcessingPostProcessId: string;
  60886. /**
  60887. * @ignore
  60888. * ID of the Fast Approximate Anti-Aliasing post process;
  60889. */
  60890. readonly FxaaPostProcessId: string;
  60891. /**
  60892. * ID of the chromatic aberration post process,
  60893. */
  60894. private readonly ChromaticAberrationPostProcessId;
  60895. /**
  60896. * ID of the grain post process
  60897. */
  60898. private readonly GrainPostProcessId;
  60899. /**
  60900. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60901. */
  60902. sharpen: SharpenPostProcess;
  60903. private _sharpenEffect;
  60904. private bloom;
  60905. /**
  60906. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60907. */
  60908. depthOfField: DepthOfFieldEffect;
  60909. /**
  60910. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60911. */
  60912. fxaa: FxaaPostProcess;
  60913. /**
  60914. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60915. */
  60916. imageProcessing: ImageProcessingPostProcess;
  60917. /**
  60918. * Chromatic aberration post process which will shift rgb colors in the image
  60919. */
  60920. chromaticAberration: ChromaticAberrationPostProcess;
  60921. private _chromaticAberrationEffect;
  60922. /**
  60923. * Grain post process which add noise to the image
  60924. */
  60925. grain: GrainPostProcess;
  60926. private _grainEffect;
  60927. /**
  60928. * Glow post process which adds a glow to emissive areas of the image
  60929. */
  60930. private _glowLayer;
  60931. /**
  60932. * Animations which can be used to tweak settings over a period of time
  60933. */
  60934. animations: Animation[];
  60935. private _imageProcessingConfigurationObserver;
  60936. private _sharpenEnabled;
  60937. private _bloomEnabled;
  60938. private _depthOfFieldEnabled;
  60939. private _depthOfFieldBlurLevel;
  60940. private _fxaaEnabled;
  60941. private _imageProcessingEnabled;
  60942. private _defaultPipelineTextureType;
  60943. private _bloomScale;
  60944. private _chromaticAberrationEnabled;
  60945. private _grainEnabled;
  60946. private _buildAllowed;
  60947. /**
  60948. * Gets active scene
  60949. */
  60950. readonly scene: Scene;
  60951. /**
  60952. * Enable or disable the sharpen process from the pipeline
  60953. */
  60954. sharpenEnabled: boolean;
  60955. private _resizeObserver;
  60956. private _hardwareScaleLevel;
  60957. private _bloomKernel;
  60958. /**
  60959. * Specifies the size of the bloom blur kernel, relative to the final output size
  60960. */
  60961. bloomKernel: number;
  60962. /**
  60963. * Specifies the weight of the bloom in the final rendering
  60964. */
  60965. private _bloomWeight;
  60966. /**
  60967. * Specifies the luma threshold for the area that will be blurred by the bloom
  60968. */
  60969. private _bloomThreshold;
  60970. private _hdr;
  60971. /**
  60972. * The strength of the bloom.
  60973. */
  60974. bloomWeight: number;
  60975. /**
  60976. * The strength of the bloom.
  60977. */
  60978. bloomThreshold: number;
  60979. /**
  60980. * The scale of the bloom, lower value will provide better performance.
  60981. */
  60982. bloomScale: number;
  60983. /**
  60984. * Enable or disable the bloom from the pipeline
  60985. */
  60986. bloomEnabled: boolean;
  60987. private _rebuildBloom;
  60988. /**
  60989. * If the depth of field is enabled.
  60990. */
  60991. depthOfFieldEnabled: boolean;
  60992. /**
  60993. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60994. */
  60995. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60996. /**
  60997. * If the anti aliasing is enabled.
  60998. */
  60999. fxaaEnabled: boolean;
  61000. private _samples;
  61001. /**
  61002. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61003. */
  61004. samples: number;
  61005. /**
  61006. * If image processing is enabled.
  61007. */
  61008. imageProcessingEnabled: boolean;
  61009. /**
  61010. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61011. */
  61012. glowLayerEnabled: boolean;
  61013. /**
  61014. * Gets the glow layer (or null if not defined)
  61015. */
  61016. readonly glowLayer: Nullable<GlowLayer>;
  61017. /**
  61018. * Enable or disable the chromaticAberration process from the pipeline
  61019. */
  61020. chromaticAberrationEnabled: boolean;
  61021. /**
  61022. * Enable or disable the grain process from the pipeline
  61023. */
  61024. grainEnabled: boolean;
  61025. /**
  61026. * @constructor
  61027. * @param name - The rendering pipeline name (default: "")
  61028. * @param hdr - If high dynamic range textures should be used (default: true)
  61029. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61030. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61031. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61032. */
  61033. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61034. /**
  61035. * Get the class name
  61036. * @returns "DefaultRenderingPipeline"
  61037. */
  61038. getClassName(): string;
  61039. /**
  61040. * Force the compilation of the entire pipeline.
  61041. */
  61042. prepare(): void;
  61043. private _hasCleared;
  61044. private _prevPostProcess;
  61045. private _prevPrevPostProcess;
  61046. private _setAutoClearAndTextureSharing;
  61047. private _depthOfFieldSceneObserver;
  61048. private _buildPipeline;
  61049. private _disposePostProcesses;
  61050. /**
  61051. * Adds a camera to the pipeline
  61052. * @param camera the camera to be added
  61053. */
  61054. addCamera(camera: Camera): void;
  61055. /**
  61056. * Removes a camera from the pipeline
  61057. * @param camera the camera to remove
  61058. */
  61059. removeCamera(camera: Camera): void;
  61060. /**
  61061. * Dispose of the pipeline and stop all post processes
  61062. */
  61063. dispose(): void;
  61064. /**
  61065. * Serialize the rendering pipeline (Used when exporting)
  61066. * @returns the serialized object
  61067. */
  61068. serialize(): any;
  61069. /**
  61070. * Parse the serialized pipeline
  61071. * @param source Source pipeline.
  61072. * @param scene The scene to load the pipeline to.
  61073. * @param rootUrl The URL of the serialized pipeline.
  61074. * @returns An instantiated pipeline from the serialized object.
  61075. */
  61076. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61077. }
  61078. }
  61079. declare module BABYLON {
  61080. /** @hidden */
  61081. export var lensHighlightsPixelShader: {
  61082. name: string;
  61083. shader: string;
  61084. };
  61085. }
  61086. declare module BABYLON {
  61087. /** @hidden */
  61088. export var depthOfFieldPixelShader: {
  61089. name: string;
  61090. shader: string;
  61091. };
  61092. }
  61093. declare module BABYLON {
  61094. /**
  61095. * BABYLON.JS Chromatic Aberration GLSL Shader
  61096. * Author: Olivier Guyot
  61097. * Separates very slightly R, G and B colors on the edges of the screen
  61098. * Inspired by Francois Tarlier & Martins Upitis
  61099. */
  61100. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61101. /**
  61102. * @ignore
  61103. * The chromatic aberration PostProcess id in the pipeline
  61104. */
  61105. LensChromaticAberrationEffect: string;
  61106. /**
  61107. * @ignore
  61108. * The highlights enhancing PostProcess id in the pipeline
  61109. */
  61110. HighlightsEnhancingEffect: string;
  61111. /**
  61112. * @ignore
  61113. * The depth-of-field PostProcess id in the pipeline
  61114. */
  61115. LensDepthOfFieldEffect: string;
  61116. private _scene;
  61117. private _depthTexture;
  61118. private _grainTexture;
  61119. private _chromaticAberrationPostProcess;
  61120. private _highlightsPostProcess;
  61121. private _depthOfFieldPostProcess;
  61122. private _edgeBlur;
  61123. private _grainAmount;
  61124. private _chromaticAberration;
  61125. private _distortion;
  61126. private _highlightsGain;
  61127. private _highlightsThreshold;
  61128. private _dofDistance;
  61129. private _dofAperture;
  61130. private _dofDarken;
  61131. private _dofPentagon;
  61132. private _blurNoise;
  61133. /**
  61134. * @constructor
  61135. *
  61136. * Effect parameters are as follow:
  61137. * {
  61138. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61139. * edge_blur: number; // from 0 to x (1 for realism)
  61140. * distortion: number; // from 0 to x (1 for realism)
  61141. * grain_amount: number; // from 0 to 1
  61142. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61143. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61144. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61145. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61146. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61147. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61148. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61149. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61150. * }
  61151. * Note: if an effect parameter is unset, effect is disabled
  61152. *
  61153. * @param name The rendering pipeline name
  61154. * @param parameters - An object containing all parameters (see above)
  61155. * @param scene The scene linked to this pipeline
  61156. * @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)
  61157. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61158. */
  61159. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61160. /**
  61161. * Get the class name
  61162. * @returns "LensRenderingPipeline"
  61163. */
  61164. getClassName(): string;
  61165. /**
  61166. * Gets associated scene
  61167. */
  61168. readonly scene: Scene;
  61169. /**
  61170. * Gets or sets the edge blur
  61171. */
  61172. edgeBlur: number;
  61173. /**
  61174. * Gets or sets the grain amount
  61175. */
  61176. grainAmount: number;
  61177. /**
  61178. * Gets or sets the chromatic aberration amount
  61179. */
  61180. chromaticAberration: number;
  61181. /**
  61182. * Gets or sets the depth of field aperture
  61183. */
  61184. dofAperture: number;
  61185. /**
  61186. * Gets or sets the edge distortion
  61187. */
  61188. edgeDistortion: number;
  61189. /**
  61190. * Gets or sets the depth of field distortion
  61191. */
  61192. dofDistortion: number;
  61193. /**
  61194. * Gets or sets the darken out of focus amount
  61195. */
  61196. darkenOutOfFocus: number;
  61197. /**
  61198. * Gets or sets a boolean indicating if blur noise is enabled
  61199. */
  61200. blurNoise: boolean;
  61201. /**
  61202. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61203. */
  61204. pentagonBokeh: boolean;
  61205. /**
  61206. * Gets or sets the highlight grain amount
  61207. */
  61208. highlightsGain: number;
  61209. /**
  61210. * Gets or sets the highlight threshold
  61211. */
  61212. highlightsThreshold: number;
  61213. /**
  61214. * Sets the amount of blur at the edges
  61215. * @param amount blur amount
  61216. */
  61217. setEdgeBlur(amount: number): void;
  61218. /**
  61219. * Sets edge blur to 0
  61220. */
  61221. disableEdgeBlur(): void;
  61222. /**
  61223. * Sets the amout of grain
  61224. * @param amount Amount of grain
  61225. */
  61226. setGrainAmount(amount: number): void;
  61227. /**
  61228. * Set grain amount to 0
  61229. */
  61230. disableGrain(): void;
  61231. /**
  61232. * Sets the chromatic aberration amount
  61233. * @param amount amount of chromatic aberration
  61234. */
  61235. setChromaticAberration(amount: number): void;
  61236. /**
  61237. * Sets chromatic aberration amount to 0
  61238. */
  61239. disableChromaticAberration(): void;
  61240. /**
  61241. * Sets the EdgeDistortion amount
  61242. * @param amount amount of EdgeDistortion
  61243. */
  61244. setEdgeDistortion(amount: number): void;
  61245. /**
  61246. * Sets edge distortion to 0
  61247. */
  61248. disableEdgeDistortion(): void;
  61249. /**
  61250. * Sets the FocusDistance amount
  61251. * @param amount amount of FocusDistance
  61252. */
  61253. setFocusDistance(amount: number): void;
  61254. /**
  61255. * Disables depth of field
  61256. */
  61257. disableDepthOfField(): void;
  61258. /**
  61259. * Sets the Aperture amount
  61260. * @param amount amount of Aperture
  61261. */
  61262. setAperture(amount: number): void;
  61263. /**
  61264. * Sets the DarkenOutOfFocus amount
  61265. * @param amount amount of DarkenOutOfFocus
  61266. */
  61267. setDarkenOutOfFocus(amount: number): void;
  61268. private _pentagonBokehIsEnabled;
  61269. /**
  61270. * Creates a pentagon bokeh effect
  61271. */
  61272. enablePentagonBokeh(): void;
  61273. /**
  61274. * Disables the pentagon bokeh effect
  61275. */
  61276. disablePentagonBokeh(): void;
  61277. /**
  61278. * Enables noise blur
  61279. */
  61280. enableNoiseBlur(): void;
  61281. /**
  61282. * Disables noise blur
  61283. */
  61284. disableNoiseBlur(): void;
  61285. /**
  61286. * Sets the HighlightsGain amount
  61287. * @param amount amount of HighlightsGain
  61288. */
  61289. setHighlightsGain(amount: number): void;
  61290. /**
  61291. * Sets the HighlightsThreshold amount
  61292. * @param amount amount of HighlightsThreshold
  61293. */
  61294. setHighlightsThreshold(amount: number): void;
  61295. /**
  61296. * Disables highlights
  61297. */
  61298. disableHighlights(): void;
  61299. /**
  61300. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61301. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61302. */
  61303. dispose(disableDepthRender?: boolean): void;
  61304. private _createChromaticAberrationPostProcess;
  61305. private _createHighlightsPostProcess;
  61306. private _createDepthOfFieldPostProcess;
  61307. private _createGrainTexture;
  61308. }
  61309. }
  61310. declare module BABYLON {
  61311. /** @hidden */
  61312. export var ssao2PixelShader: {
  61313. name: string;
  61314. shader: string;
  61315. };
  61316. }
  61317. declare module BABYLON {
  61318. /** @hidden */
  61319. export var ssaoCombinePixelShader: {
  61320. name: string;
  61321. shader: string;
  61322. };
  61323. }
  61324. declare module BABYLON {
  61325. /**
  61326. * Render pipeline to produce ssao effect
  61327. */
  61328. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61329. /**
  61330. * @ignore
  61331. * The PassPostProcess id in the pipeline that contains the original scene color
  61332. */
  61333. SSAOOriginalSceneColorEffect: string;
  61334. /**
  61335. * @ignore
  61336. * The SSAO PostProcess id in the pipeline
  61337. */
  61338. SSAORenderEffect: string;
  61339. /**
  61340. * @ignore
  61341. * The horizontal blur PostProcess id in the pipeline
  61342. */
  61343. SSAOBlurHRenderEffect: string;
  61344. /**
  61345. * @ignore
  61346. * The vertical blur PostProcess id in the pipeline
  61347. */
  61348. SSAOBlurVRenderEffect: string;
  61349. /**
  61350. * @ignore
  61351. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61352. */
  61353. SSAOCombineRenderEffect: string;
  61354. /**
  61355. * The output strength of the SSAO post-process. Default value is 1.0.
  61356. */
  61357. totalStrength: number;
  61358. /**
  61359. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61360. */
  61361. maxZ: number;
  61362. /**
  61363. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61364. */
  61365. minZAspect: number;
  61366. private _samples;
  61367. /**
  61368. * Number of samples used for the SSAO calculations. Default value is 8
  61369. */
  61370. samples: number;
  61371. private _textureSamples;
  61372. /**
  61373. * Number of samples to use for antialiasing
  61374. */
  61375. textureSamples: number;
  61376. /**
  61377. * Ratio object used for SSAO ratio and blur ratio
  61378. */
  61379. private _ratio;
  61380. /**
  61381. * Dynamically generated sphere sampler.
  61382. */
  61383. private _sampleSphere;
  61384. /**
  61385. * Blur filter offsets
  61386. */
  61387. private _samplerOffsets;
  61388. private _expensiveBlur;
  61389. /**
  61390. * If bilateral blur should be used
  61391. */
  61392. expensiveBlur: boolean;
  61393. /**
  61394. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61395. */
  61396. radius: number;
  61397. /**
  61398. * The base color of the SSAO post-process
  61399. * The final result is "base + ssao" between [0, 1]
  61400. */
  61401. base: number;
  61402. /**
  61403. * Support test.
  61404. */
  61405. static readonly IsSupported: boolean;
  61406. private _scene;
  61407. private _depthTexture;
  61408. private _normalTexture;
  61409. private _randomTexture;
  61410. private _originalColorPostProcess;
  61411. private _ssaoPostProcess;
  61412. private _blurHPostProcess;
  61413. private _blurVPostProcess;
  61414. private _ssaoCombinePostProcess;
  61415. private _firstUpdate;
  61416. /**
  61417. * Gets active scene
  61418. */
  61419. readonly scene: Scene;
  61420. /**
  61421. * @constructor
  61422. * @param name The rendering pipeline name
  61423. * @param scene The scene linked to this pipeline
  61424. * @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 }
  61425. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61426. */
  61427. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61428. /**
  61429. * Get the class name
  61430. * @returns "SSAO2RenderingPipeline"
  61431. */
  61432. getClassName(): string;
  61433. /**
  61434. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61435. */
  61436. dispose(disableGeometryBufferRenderer?: boolean): void;
  61437. private _createBlurPostProcess;
  61438. /** @hidden */
  61439. _rebuild(): void;
  61440. private _bits;
  61441. private _radicalInverse_VdC;
  61442. private _hammersley;
  61443. private _hemisphereSample_uniform;
  61444. private _generateHemisphere;
  61445. private _createSSAOPostProcess;
  61446. private _createSSAOCombinePostProcess;
  61447. private _createRandomTexture;
  61448. /**
  61449. * Serialize the rendering pipeline (Used when exporting)
  61450. * @returns the serialized object
  61451. */
  61452. serialize(): any;
  61453. /**
  61454. * Parse the serialized pipeline
  61455. * @param source Source pipeline.
  61456. * @param scene The scene to load the pipeline to.
  61457. * @param rootUrl The URL of the serialized pipeline.
  61458. * @returns An instantiated pipeline from the serialized object.
  61459. */
  61460. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61461. }
  61462. }
  61463. declare module BABYLON {
  61464. /** @hidden */
  61465. export var ssaoPixelShader: {
  61466. name: string;
  61467. shader: string;
  61468. };
  61469. }
  61470. declare module BABYLON {
  61471. /**
  61472. * Render pipeline to produce ssao effect
  61473. */
  61474. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61475. /**
  61476. * @ignore
  61477. * The PassPostProcess id in the pipeline that contains the original scene color
  61478. */
  61479. SSAOOriginalSceneColorEffect: string;
  61480. /**
  61481. * @ignore
  61482. * The SSAO PostProcess id in the pipeline
  61483. */
  61484. SSAORenderEffect: string;
  61485. /**
  61486. * @ignore
  61487. * The horizontal blur PostProcess id in the pipeline
  61488. */
  61489. SSAOBlurHRenderEffect: string;
  61490. /**
  61491. * @ignore
  61492. * The vertical blur PostProcess id in the pipeline
  61493. */
  61494. SSAOBlurVRenderEffect: string;
  61495. /**
  61496. * @ignore
  61497. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61498. */
  61499. SSAOCombineRenderEffect: string;
  61500. /**
  61501. * The output strength of the SSAO post-process. Default value is 1.0.
  61502. */
  61503. totalStrength: number;
  61504. /**
  61505. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61506. */
  61507. radius: number;
  61508. /**
  61509. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61510. * Must not be equal to fallOff and superior to fallOff.
  61511. * Default value is 0.0075
  61512. */
  61513. area: number;
  61514. /**
  61515. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61516. * Must not be equal to area and inferior to area.
  61517. * Default value is 0.000001
  61518. */
  61519. fallOff: number;
  61520. /**
  61521. * The base color of the SSAO post-process
  61522. * The final result is "base + ssao" between [0, 1]
  61523. */
  61524. base: number;
  61525. private _scene;
  61526. private _depthTexture;
  61527. private _randomTexture;
  61528. private _originalColorPostProcess;
  61529. private _ssaoPostProcess;
  61530. private _blurHPostProcess;
  61531. private _blurVPostProcess;
  61532. private _ssaoCombinePostProcess;
  61533. private _firstUpdate;
  61534. /**
  61535. * Gets active scene
  61536. */
  61537. readonly scene: Scene;
  61538. /**
  61539. * @constructor
  61540. * @param name - The rendering pipeline name
  61541. * @param scene - The scene linked to this pipeline
  61542. * @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 }
  61543. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61544. */
  61545. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61546. /**
  61547. * Get the class name
  61548. * @returns "SSAORenderingPipeline"
  61549. */
  61550. getClassName(): string;
  61551. /**
  61552. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61553. */
  61554. dispose(disableDepthRender?: boolean): void;
  61555. private _createBlurPostProcess;
  61556. /** @hidden */
  61557. _rebuild(): void;
  61558. private _createSSAOPostProcess;
  61559. private _createSSAOCombinePostProcess;
  61560. private _createRandomTexture;
  61561. }
  61562. }
  61563. declare module BABYLON {
  61564. /** @hidden */
  61565. export var standardPixelShader: {
  61566. name: string;
  61567. shader: string;
  61568. };
  61569. }
  61570. declare module BABYLON {
  61571. /**
  61572. * Standard rendering pipeline
  61573. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61574. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61575. */
  61576. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61577. /**
  61578. * Public members
  61579. */
  61580. /**
  61581. * Post-process which contains the original scene color before the pipeline applies all the effects
  61582. */
  61583. originalPostProcess: Nullable<PostProcess>;
  61584. /**
  61585. * Post-process used to down scale an image x4
  61586. */
  61587. downSampleX4PostProcess: Nullable<PostProcess>;
  61588. /**
  61589. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61590. */
  61591. brightPassPostProcess: Nullable<PostProcess>;
  61592. /**
  61593. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61594. */
  61595. blurHPostProcesses: PostProcess[];
  61596. /**
  61597. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61598. */
  61599. blurVPostProcesses: PostProcess[];
  61600. /**
  61601. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61602. */
  61603. textureAdderPostProcess: Nullable<PostProcess>;
  61604. /**
  61605. * Post-process used to create volumetric lighting effect
  61606. */
  61607. volumetricLightPostProcess: Nullable<PostProcess>;
  61608. /**
  61609. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61610. */
  61611. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61612. /**
  61613. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61614. */
  61615. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61616. /**
  61617. * Post-process used to merge the volumetric light effect and the real scene color
  61618. */
  61619. volumetricLightMergePostProces: Nullable<PostProcess>;
  61620. /**
  61621. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61622. */
  61623. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61624. /**
  61625. * Base post-process used to calculate the average luminance of the final image for HDR
  61626. */
  61627. luminancePostProcess: Nullable<PostProcess>;
  61628. /**
  61629. * Post-processes used to create down sample post-processes in order to get
  61630. * the average luminance of the final image for HDR
  61631. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61632. */
  61633. luminanceDownSamplePostProcesses: PostProcess[];
  61634. /**
  61635. * Post-process used to create a HDR effect (light adaptation)
  61636. */
  61637. hdrPostProcess: Nullable<PostProcess>;
  61638. /**
  61639. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61640. */
  61641. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61642. /**
  61643. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61644. */
  61645. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61646. /**
  61647. * Post-process used to merge the final HDR post-process and the real scene color
  61648. */
  61649. hdrFinalPostProcess: Nullable<PostProcess>;
  61650. /**
  61651. * Post-process used to create a lens flare effect
  61652. */
  61653. lensFlarePostProcess: Nullable<PostProcess>;
  61654. /**
  61655. * Post-process that merges the result of the lens flare post-process and the real scene color
  61656. */
  61657. lensFlareComposePostProcess: Nullable<PostProcess>;
  61658. /**
  61659. * Post-process used to create a motion blur effect
  61660. */
  61661. motionBlurPostProcess: Nullable<PostProcess>;
  61662. /**
  61663. * Post-process used to create a depth of field effect
  61664. */
  61665. depthOfFieldPostProcess: Nullable<PostProcess>;
  61666. /**
  61667. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61668. */
  61669. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61670. /**
  61671. * Represents the brightness threshold in order to configure the illuminated surfaces
  61672. */
  61673. brightThreshold: number;
  61674. /**
  61675. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61676. */
  61677. blurWidth: number;
  61678. /**
  61679. * Sets if the blur for highlighted surfaces must be only horizontal
  61680. */
  61681. horizontalBlur: boolean;
  61682. /**
  61683. * Gets the overall exposure used by the pipeline
  61684. */
  61685. /**
  61686. * Sets the overall exposure used by the pipeline
  61687. */
  61688. exposure: number;
  61689. /**
  61690. * Texture used typically to simulate "dirty" on camera lens
  61691. */
  61692. lensTexture: Nullable<Texture>;
  61693. /**
  61694. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61695. */
  61696. volumetricLightCoefficient: number;
  61697. /**
  61698. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61699. */
  61700. volumetricLightPower: number;
  61701. /**
  61702. * Used the set the blur intensity to smooth the volumetric lights
  61703. */
  61704. volumetricLightBlurScale: number;
  61705. /**
  61706. * Light (spot or directional) used to generate the volumetric lights rays
  61707. * The source light must have a shadow generate so the pipeline can get its
  61708. * depth map
  61709. */
  61710. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61711. /**
  61712. * For eye adaptation, represents the minimum luminance the eye can see
  61713. */
  61714. hdrMinimumLuminance: number;
  61715. /**
  61716. * For eye adaptation, represents the decrease luminance speed
  61717. */
  61718. hdrDecreaseRate: number;
  61719. /**
  61720. * For eye adaptation, represents the increase luminance speed
  61721. */
  61722. hdrIncreaseRate: number;
  61723. /**
  61724. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61725. */
  61726. /**
  61727. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61728. */
  61729. hdrAutoExposure: boolean;
  61730. /**
  61731. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61732. */
  61733. lensColorTexture: Nullable<Texture>;
  61734. /**
  61735. * The overall strengh for the lens flare effect
  61736. */
  61737. lensFlareStrength: number;
  61738. /**
  61739. * Dispersion coefficient for lens flare ghosts
  61740. */
  61741. lensFlareGhostDispersal: number;
  61742. /**
  61743. * Main lens flare halo width
  61744. */
  61745. lensFlareHaloWidth: number;
  61746. /**
  61747. * Based on the lens distortion effect, defines how much the lens flare result
  61748. * is distorted
  61749. */
  61750. lensFlareDistortionStrength: number;
  61751. /**
  61752. * Configures the blur intensity used for for lens flare (halo)
  61753. */
  61754. lensFlareBlurWidth: number;
  61755. /**
  61756. * Lens star texture must be used to simulate rays on the flares and is available
  61757. * in the documentation
  61758. */
  61759. lensStarTexture: Nullable<Texture>;
  61760. /**
  61761. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61762. * flare effect by taking account of the dirt texture
  61763. */
  61764. lensFlareDirtTexture: Nullable<Texture>;
  61765. /**
  61766. * Represents the focal length for the depth of field effect
  61767. */
  61768. depthOfFieldDistance: number;
  61769. /**
  61770. * Represents the blur intensity for the blurred part of the depth of field effect
  61771. */
  61772. depthOfFieldBlurWidth: number;
  61773. /**
  61774. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61775. */
  61776. /**
  61777. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61778. */
  61779. motionStrength: number;
  61780. /**
  61781. * Gets wether or not the motion blur post-process is object based or screen based.
  61782. */
  61783. /**
  61784. * Sets wether or not the motion blur post-process should be object based or screen based
  61785. */
  61786. objectBasedMotionBlur: boolean;
  61787. /**
  61788. * List of animations for the pipeline (IAnimatable implementation)
  61789. */
  61790. animations: Animation[];
  61791. /**
  61792. * Private members
  61793. */
  61794. private _scene;
  61795. private _currentDepthOfFieldSource;
  61796. private _basePostProcess;
  61797. private _fixedExposure;
  61798. private _currentExposure;
  61799. private _hdrAutoExposure;
  61800. private _hdrCurrentLuminance;
  61801. private _motionStrength;
  61802. private _isObjectBasedMotionBlur;
  61803. private _floatTextureType;
  61804. private _camerasToBeAttached;
  61805. private _ratio;
  61806. private _bloomEnabled;
  61807. private _depthOfFieldEnabled;
  61808. private _vlsEnabled;
  61809. private _lensFlareEnabled;
  61810. private _hdrEnabled;
  61811. private _motionBlurEnabled;
  61812. private _fxaaEnabled;
  61813. private _motionBlurSamples;
  61814. private _volumetricLightStepsCount;
  61815. private _samples;
  61816. /**
  61817. * @ignore
  61818. * Specifies if the bloom pipeline is enabled
  61819. */
  61820. BloomEnabled: boolean;
  61821. /**
  61822. * @ignore
  61823. * Specifies if the depth of field pipeline is enabed
  61824. */
  61825. DepthOfFieldEnabled: boolean;
  61826. /**
  61827. * @ignore
  61828. * Specifies if the lens flare pipeline is enabed
  61829. */
  61830. LensFlareEnabled: boolean;
  61831. /**
  61832. * @ignore
  61833. * Specifies if the HDR pipeline is enabled
  61834. */
  61835. HDREnabled: boolean;
  61836. /**
  61837. * @ignore
  61838. * Specifies if the volumetric lights scattering effect is enabled
  61839. */
  61840. VLSEnabled: boolean;
  61841. /**
  61842. * @ignore
  61843. * Specifies if the motion blur effect is enabled
  61844. */
  61845. MotionBlurEnabled: boolean;
  61846. /**
  61847. * Specifies if anti-aliasing is enabled
  61848. */
  61849. fxaaEnabled: boolean;
  61850. /**
  61851. * Specifies the number of steps used to calculate the volumetric lights
  61852. * Typically in interval [50, 200]
  61853. */
  61854. volumetricLightStepsCount: number;
  61855. /**
  61856. * Specifies the number of samples used for the motion blur effect
  61857. * Typically in interval [16, 64]
  61858. */
  61859. motionBlurSamples: number;
  61860. /**
  61861. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61862. */
  61863. samples: number;
  61864. /**
  61865. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61866. * @constructor
  61867. * @param name The rendering pipeline name
  61868. * @param scene The scene linked to this pipeline
  61869. * @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)
  61870. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61871. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61872. */
  61873. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61874. private _buildPipeline;
  61875. private _createDownSampleX4PostProcess;
  61876. private _createBrightPassPostProcess;
  61877. private _createBlurPostProcesses;
  61878. private _createTextureAdderPostProcess;
  61879. private _createVolumetricLightPostProcess;
  61880. private _createLuminancePostProcesses;
  61881. private _createHdrPostProcess;
  61882. private _createLensFlarePostProcess;
  61883. private _createDepthOfFieldPostProcess;
  61884. private _createMotionBlurPostProcess;
  61885. private _getDepthTexture;
  61886. private _disposePostProcesses;
  61887. /**
  61888. * Dispose of the pipeline and stop all post processes
  61889. */
  61890. dispose(): void;
  61891. /**
  61892. * Serialize the rendering pipeline (Used when exporting)
  61893. * @returns the serialized object
  61894. */
  61895. serialize(): any;
  61896. /**
  61897. * Parse the serialized pipeline
  61898. * @param source Source pipeline.
  61899. * @param scene The scene to load the pipeline to.
  61900. * @param rootUrl The URL of the serialized pipeline.
  61901. * @returns An instantiated pipeline from the serialized object.
  61902. */
  61903. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61904. /**
  61905. * Luminance steps
  61906. */
  61907. static LuminanceSteps: number;
  61908. }
  61909. }
  61910. declare module BABYLON {
  61911. /** @hidden */
  61912. export var tonemapPixelShader: {
  61913. name: string;
  61914. shader: string;
  61915. };
  61916. }
  61917. declare module BABYLON {
  61918. /** Defines operator used for tonemapping */
  61919. export enum TonemappingOperator {
  61920. /** Hable */
  61921. Hable = 0,
  61922. /** Reinhard */
  61923. Reinhard = 1,
  61924. /** HejiDawson */
  61925. HejiDawson = 2,
  61926. /** Photographic */
  61927. Photographic = 3
  61928. }
  61929. /**
  61930. * Defines a post process to apply tone mapping
  61931. */
  61932. export class TonemapPostProcess extends PostProcess {
  61933. private _operator;
  61934. /** Defines the required exposure adjustement */
  61935. exposureAdjustment: number;
  61936. /**
  61937. * Creates a new TonemapPostProcess
  61938. * @param name defines the name of the postprocess
  61939. * @param _operator defines the operator to use
  61940. * @param exposureAdjustment defines the required exposure adjustement
  61941. * @param camera defines the camera to use (can be null)
  61942. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61943. * @param engine defines the hosting engine (can be ignore if camera is set)
  61944. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61945. */
  61946. constructor(name: string, _operator: TonemappingOperator,
  61947. /** Defines the required exposure adjustement */
  61948. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61949. }
  61950. }
  61951. declare module BABYLON {
  61952. /** @hidden */
  61953. export var depthVertexShader: {
  61954. name: string;
  61955. shader: string;
  61956. };
  61957. }
  61958. declare module BABYLON {
  61959. /** @hidden */
  61960. export var volumetricLightScatteringPixelShader: {
  61961. name: string;
  61962. shader: string;
  61963. };
  61964. }
  61965. declare module BABYLON {
  61966. /** @hidden */
  61967. export var volumetricLightScatteringPassVertexShader: {
  61968. name: string;
  61969. shader: string;
  61970. };
  61971. }
  61972. declare module BABYLON {
  61973. /** @hidden */
  61974. export var volumetricLightScatteringPassPixelShader: {
  61975. name: string;
  61976. shader: string;
  61977. };
  61978. }
  61979. declare module BABYLON {
  61980. /**
  61981. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61982. */
  61983. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61984. private _volumetricLightScatteringPass;
  61985. private _volumetricLightScatteringRTT;
  61986. private _viewPort;
  61987. private _screenCoordinates;
  61988. private _cachedDefines;
  61989. /**
  61990. * If not undefined, the mesh position is computed from the attached node position
  61991. */
  61992. attachedNode: {
  61993. position: Vector3;
  61994. };
  61995. /**
  61996. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61997. */
  61998. customMeshPosition: Vector3;
  61999. /**
  62000. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62001. */
  62002. useCustomMeshPosition: boolean;
  62003. /**
  62004. * If the post-process should inverse the light scattering direction
  62005. */
  62006. invert: boolean;
  62007. /**
  62008. * The internal mesh used by the post-process
  62009. */
  62010. mesh: Mesh;
  62011. /**
  62012. * @hidden
  62013. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62014. */
  62015. useDiffuseColor: boolean;
  62016. /**
  62017. * Array containing the excluded meshes not rendered in the internal pass
  62018. */
  62019. excludedMeshes: AbstractMesh[];
  62020. /**
  62021. * Controls the overall intensity of the post-process
  62022. */
  62023. exposure: number;
  62024. /**
  62025. * Dissipates each sample's contribution in range [0, 1]
  62026. */
  62027. decay: number;
  62028. /**
  62029. * Controls the overall intensity of each sample
  62030. */
  62031. weight: number;
  62032. /**
  62033. * Controls the density of each sample
  62034. */
  62035. density: number;
  62036. /**
  62037. * @constructor
  62038. * @param name The post-process name
  62039. * @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)
  62040. * @param camera The camera that the post-process will be attached to
  62041. * @param mesh The mesh used to create the light scattering
  62042. * @param samples The post-process quality, default 100
  62043. * @param samplingModeThe post-process filtering mode
  62044. * @param engine The babylon engine
  62045. * @param reusable If the post-process is reusable
  62046. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62047. */
  62048. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62049. /**
  62050. * Returns the string "VolumetricLightScatteringPostProcess"
  62051. * @returns "VolumetricLightScatteringPostProcess"
  62052. */
  62053. getClassName(): string;
  62054. private _isReady;
  62055. /**
  62056. * Sets the new light position for light scattering effect
  62057. * @param position The new custom light position
  62058. */
  62059. setCustomMeshPosition(position: Vector3): void;
  62060. /**
  62061. * Returns the light position for light scattering effect
  62062. * @return Vector3 The custom light position
  62063. */
  62064. getCustomMeshPosition(): Vector3;
  62065. /**
  62066. * Disposes the internal assets and detaches the post-process from the camera
  62067. */
  62068. dispose(camera: Camera): void;
  62069. /**
  62070. * Returns the render target texture used by the post-process
  62071. * @return the render target texture used by the post-process
  62072. */
  62073. getPass(): RenderTargetTexture;
  62074. private _meshExcluded;
  62075. private _createPass;
  62076. private _updateMeshScreenCoordinates;
  62077. /**
  62078. * Creates a default mesh for the Volumeric Light Scattering post-process
  62079. * @param name The mesh name
  62080. * @param scene The scene where to create the mesh
  62081. * @return the default mesh
  62082. */
  62083. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62084. }
  62085. }
  62086. declare module BABYLON {
  62087. interface Scene {
  62088. /** @hidden (Backing field) */
  62089. _boundingBoxRenderer: BoundingBoxRenderer;
  62090. /** @hidden (Backing field) */
  62091. _forceShowBoundingBoxes: boolean;
  62092. /**
  62093. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62094. */
  62095. forceShowBoundingBoxes: boolean;
  62096. /**
  62097. * Gets the bounding box renderer associated with the scene
  62098. * @returns a BoundingBoxRenderer
  62099. */
  62100. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62101. }
  62102. interface AbstractMesh {
  62103. /** @hidden (Backing field) */
  62104. _showBoundingBox: boolean;
  62105. /**
  62106. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62107. */
  62108. showBoundingBox: boolean;
  62109. }
  62110. /**
  62111. * Component responsible of rendering the bounding box of the meshes in a scene.
  62112. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62113. */
  62114. export class BoundingBoxRenderer implements ISceneComponent {
  62115. /**
  62116. * The component name helpfull to identify the component in the list of scene components.
  62117. */
  62118. readonly name: string;
  62119. /**
  62120. * The scene the component belongs to.
  62121. */
  62122. scene: Scene;
  62123. /**
  62124. * Color of the bounding box lines placed in front of an object
  62125. */
  62126. frontColor: Color3;
  62127. /**
  62128. * Color of the bounding box lines placed behind an object
  62129. */
  62130. backColor: Color3;
  62131. /**
  62132. * Defines if the renderer should show the back lines or not
  62133. */
  62134. showBackLines: boolean;
  62135. /**
  62136. * @hidden
  62137. */
  62138. renderList: SmartArray<BoundingBox>;
  62139. private _colorShader;
  62140. private _vertexBuffers;
  62141. private _indexBuffer;
  62142. private _fillIndexBuffer;
  62143. private _fillIndexData;
  62144. /**
  62145. * Instantiates a new bounding box renderer in a scene.
  62146. * @param scene the scene the renderer renders in
  62147. */
  62148. constructor(scene: Scene);
  62149. /**
  62150. * Registers the component in a given scene
  62151. */
  62152. register(): void;
  62153. private _evaluateSubMesh;
  62154. private _activeMesh;
  62155. private _prepareRessources;
  62156. private _createIndexBuffer;
  62157. /**
  62158. * Rebuilds the elements related to this component in case of
  62159. * context lost for instance.
  62160. */
  62161. rebuild(): void;
  62162. /**
  62163. * @hidden
  62164. */
  62165. reset(): void;
  62166. /**
  62167. * Render the bounding boxes of a specific rendering group
  62168. * @param renderingGroupId defines the rendering group to render
  62169. */
  62170. render(renderingGroupId: number): void;
  62171. /**
  62172. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62173. * @param mesh Define the mesh to render the occlusion bounding box for
  62174. */
  62175. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62176. /**
  62177. * Dispose and release the resources attached to this renderer.
  62178. */
  62179. dispose(): void;
  62180. }
  62181. }
  62182. declare module BABYLON {
  62183. /** @hidden */
  62184. export var depthPixelShader: {
  62185. name: string;
  62186. shader: string;
  62187. };
  62188. }
  62189. declare module BABYLON {
  62190. /**
  62191. * This represents a depth renderer in Babylon.
  62192. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62193. */
  62194. export class DepthRenderer {
  62195. private _scene;
  62196. private _depthMap;
  62197. private _effect;
  62198. private readonly _storeNonLinearDepth;
  62199. private readonly _clearColor;
  62200. /** Get if the depth renderer is using packed depth or not */
  62201. readonly isPacked: boolean;
  62202. private _cachedDefines;
  62203. private _camera;
  62204. /**
  62205. * Specifiess that the depth renderer will only be used within
  62206. * the camera it is created for.
  62207. * This can help forcing its rendering during the camera processing.
  62208. */
  62209. useOnlyInActiveCamera: boolean;
  62210. /** @hidden */
  62211. static _SceneComponentInitialization: (scene: Scene) => void;
  62212. /**
  62213. * Instantiates a depth renderer
  62214. * @param scene The scene the renderer belongs to
  62215. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62216. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62217. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62218. */
  62219. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62220. /**
  62221. * Creates the depth rendering effect and checks if the effect is ready.
  62222. * @param subMesh The submesh to be used to render the depth map of
  62223. * @param useInstances If multiple world instances should be used
  62224. * @returns if the depth renderer is ready to render the depth map
  62225. */
  62226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62227. /**
  62228. * Gets the texture which the depth map will be written to.
  62229. * @returns The depth map texture
  62230. */
  62231. getDepthMap(): RenderTargetTexture;
  62232. /**
  62233. * Disposes of the depth renderer.
  62234. */
  62235. dispose(): void;
  62236. }
  62237. }
  62238. declare module BABYLON {
  62239. interface Scene {
  62240. /** @hidden (Backing field) */
  62241. _depthRenderer: {
  62242. [id: string]: DepthRenderer;
  62243. };
  62244. /**
  62245. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62246. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62247. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62248. * @returns the created depth renderer
  62249. */
  62250. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62251. /**
  62252. * Disables a depth renderer for a given camera
  62253. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62254. */
  62255. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62256. }
  62257. /**
  62258. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62259. * in several rendering techniques.
  62260. */
  62261. export class DepthRendererSceneComponent implements ISceneComponent {
  62262. /**
  62263. * The component name helpfull to identify the component in the list of scene components.
  62264. */
  62265. readonly name: string;
  62266. /**
  62267. * The scene the component belongs to.
  62268. */
  62269. scene: Scene;
  62270. /**
  62271. * Creates a new instance of the component for the given scene
  62272. * @param scene Defines the scene to register the component in
  62273. */
  62274. constructor(scene: Scene);
  62275. /**
  62276. * Registers the component in a given scene
  62277. */
  62278. register(): void;
  62279. /**
  62280. * Rebuilds the elements related to this component in case of
  62281. * context lost for instance.
  62282. */
  62283. rebuild(): void;
  62284. /**
  62285. * Disposes the component and the associated ressources
  62286. */
  62287. dispose(): void;
  62288. private _gatherRenderTargets;
  62289. private _gatherActiveCameraRenderTargets;
  62290. }
  62291. }
  62292. declare module BABYLON {
  62293. /** @hidden */
  62294. export var outlinePixelShader: {
  62295. name: string;
  62296. shader: string;
  62297. };
  62298. }
  62299. declare module BABYLON {
  62300. /** @hidden */
  62301. export var outlineVertexShader: {
  62302. name: string;
  62303. shader: string;
  62304. };
  62305. }
  62306. declare module BABYLON {
  62307. interface Scene {
  62308. /** @hidden */
  62309. _outlineRenderer: OutlineRenderer;
  62310. /**
  62311. * Gets the outline renderer associated with the scene
  62312. * @returns a OutlineRenderer
  62313. */
  62314. getOutlineRenderer(): OutlineRenderer;
  62315. }
  62316. interface AbstractMesh {
  62317. /** @hidden (Backing field) */
  62318. _renderOutline: boolean;
  62319. /**
  62320. * Gets or sets a boolean indicating if the outline must be rendered as well
  62321. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62322. */
  62323. renderOutline: boolean;
  62324. /** @hidden (Backing field) */
  62325. _renderOverlay: boolean;
  62326. /**
  62327. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62328. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62329. */
  62330. renderOverlay: boolean;
  62331. }
  62332. /**
  62333. * This class is responsible to draw bothe outline/overlay of meshes.
  62334. * It should not be used directly but through the available method on mesh.
  62335. */
  62336. export class OutlineRenderer implements ISceneComponent {
  62337. /**
  62338. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62339. */
  62340. private static _StencilReference;
  62341. /**
  62342. * The name of the component. Each component must have a unique name.
  62343. */
  62344. name: string;
  62345. /**
  62346. * The scene the component belongs to.
  62347. */
  62348. scene: Scene;
  62349. /**
  62350. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62351. */
  62352. zOffset: number;
  62353. private _engine;
  62354. private _effect;
  62355. private _cachedDefines;
  62356. private _savedDepthWrite;
  62357. /**
  62358. * Instantiates a new outline renderer. (There could be only one per scene).
  62359. * @param scene Defines the scene it belongs to
  62360. */
  62361. constructor(scene: Scene);
  62362. /**
  62363. * Register the component to one instance of a scene.
  62364. */
  62365. register(): void;
  62366. /**
  62367. * Rebuilds the elements related to this component in case of
  62368. * context lost for instance.
  62369. */
  62370. rebuild(): void;
  62371. /**
  62372. * Disposes the component and the associated ressources.
  62373. */
  62374. dispose(): void;
  62375. /**
  62376. * Renders the outline in the canvas.
  62377. * @param subMesh Defines the sumesh to render
  62378. * @param batch Defines the batch of meshes in case of instances
  62379. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62380. */
  62381. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62382. /**
  62383. * Returns whether or not the outline renderer is ready for a given submesh.
  62384. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62385. * @param subMesh Defines the submesh to check readyness for
  62386. * @param useInstances Defines wheter wee are trying to render instances or not
  62387. * @returns true if ready otherwise false
  62388. */
  62389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62390. private _beforeRenderingMesh;
  62391. private _afterRenderingMesh;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62397. * @see http://doc.babylonjs.com/babylon101/sprites
  62398. */
  62399. export class SpritePackedManager extends SpriteManager {
  62400. /** defines the packed manager's name */
  62401. name: string;
  62402. /**
  62403. * Creates a new sprite manager from a packed sprite sheet
  62404. * @param name defines the manager's name
  62405. * @param imgUrl defines the sprite sheet url
  62406. * @param capacity defines the maximum allowed number of sprites
  62407. * @param scene defines the hosting scene
  62408. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62409. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62410. * @param samplingMode defines the smapling mode to use with spritesheet
  62411. * @param fromPacked set to true; do not alter
  62412. */
  62413. constructor(
  62414. /** defines the packed manager's name */
  62415. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62416. }
  62417. }
  62418. declare module BABYLON {
  62419. /**
  62420. * Defines the list of states available for a task inside a AssetsManager
  62421. */
  62422. export enum AssetTaskState {
  62423. /**
  62424. * Initialization
  62425. */
  62426. INIT = 0,
  62427. /**
  62428. * Running
  62429. */
  62430. RUNNING = 1,
  62431. /**
  62432. * Done
  62433. */
  62434. DONE = 2,
  62435. /**
  62436. * Error
  62437. */
  62438. ERROR = 3
  62439. }
  62440. /**
  62441. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62442. */
  62443. export abstract class AbstractAssetTask {
  62444. /**
  62445. * Task name
  62446. */ name: string;
  62447. /**
  62448. * Callback called when the task is successful
  62449. */
  62450. onSuccess: (task: any) => void;
  62451. /**
  62452. * Callback called when the task is not successful
  62453. */
  62454. onError: (task: any, message?: string, exception?: any) => void;
  62455. /**
  62456. * Creates a new AssetsManager
  62457. * @param name defines the name of the task
  62458. */
  62459. constructor(
  62460. /**
  62461. * Task name
  62462. */ name: string);
  62463. private _isCompleted;
  62464. private _taskState;
  62465. private _errorObject;
  62466. /**
  62467. * Get if the task is completed
  62468. */
  62469. readonly isCompleted: boolean;
  62470. /**
  62471. * Gets the current state of the task
  62472. */
  62473. readonly taskState: AssetTaskState;
  62474. /**
  62475. * Gets the current error object (if task is in error)
  62476. */
  62477. readonly errorObject: {
  62478. message?: string;
  62479. exception?: any;
  62480. };
  62481. /**
  62482. * Internal only
  62483. * @hidden
  62484. */
  62485. _setErrorObject(message?: string, exception?: any): void;
  62486. /**
  62487. * Execute the current task
  62488. * @param scene defines the scene where you want your assets to be loaded
  62489. * @param onSuccess is a callback called when the task is successfully executed
  62490. * @param onError is a callback called if an error occurs
  62491. */
  62492. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62493. /**
  62494. * Execute the current task
  62495. * @param scene defines the scene where you want your assets to be loaded
  62496. * @param onSuccess is a callback called when the task is successfully executed
  62497. * @param onError is a callback called if an error occurs
  62498. */
  62499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62500. /**
  62501. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62502. * This can be used with failed tasks that have the reason for failure fixed.
  62503. */
  62504. reset(): void;
  62505. private onErrorCallback;
  62506. private onDoneCallback;
  62507. }
  62508. /**
  62509. * Define the interface used by progress events raised during assets loading
  62510. */
  62511. export interface IAssetsProgressEvent {
  62512. /**
  62513. * Defines the number of remaining tasks to process
  62514. */
  62515. remainingCount: number;
  62516. /**
  62517. * Defines the total number of tasks
  62518. */
  62519. totalCount: number;
  62520. /**
  62521. * Defines the task that was just processed
  62522. */
  62523. task: AbstractAssetTask;
  62524. }
  62525. /**
  62526. * Class used to share progress information about assets loading
  62527. */
  62528. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62529. /**
  62530. * Defines the number of remaining tasks to process
  62531. */
  62532. remainingCount: number;
  62533. /**
  62534. * Defines the total number of tasks
  62535. */
  62536. totalCount: number;
  62537. /**
  62538. * Defines the task that was just processed
  62539. */
  62540. task: AbstractAssetTask;
  62541. /**
  62542. * Creates a AssetsProgressEvent
  62543. * @param remainingCount defines the number of remaining tasks to process
  62544. * @param totalCount defines the total number of tasks
  62545. * @param task defines the task that was just processed
  62546. */
  62547. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62548. }
  62549. /**
  62550. * Define a task used by AssetsManager to load meshes
  62551. */
  62552. export class MeshAssetTask extends AbstractAssetTask {
  62553. /**
  62554. * Defines the name of the task
  62555. */
  62556. name: string;
  62557. /**
  62558. * Defines the list of mesh's names you want to load
  62559. */
  62560. meshesNames: any;
  62561. /**
  62562. * Defines the root url to use as a base to load your meshes and associated resources
  62563. */
  62564. rootUrl: string;
  62565. /**
  62566. * Defines the filename of the scene to load from
  62567. */
  62568. sceneFilename: string;
  62569. /**
  62570. * Gets the list of loaded meshes
  62571. */
  62572. loadedMeshes: Array<AbstractMesh>;
  62573. /**
  62574. * Gets the list of loaded particle systems
  62575. */
  62576. loadedParticleSystems: Array<IParticleSystem>;
  62577. /**
  62578. * Gets the list of loaded skeletons
  62579. */
  62580. loadedSkeletons: Array<Skeleton>;
  62581. /**
  62582. * Gets the list of loaded animation groups
  62583. */
  62584. loadedAnimationGroups: Array<AnimationGroup>;
  62585. /**
  62586. * Callback called when the task is successful
  62587. */
  62588. onSuccess: (task: MeshAssetTask) => void;
  62589. /**
  62590. * Callback called when the task is successful
  62591. */
  62592. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62593. /**
  62594. * Creates a new MeshAssetTask
  62595. * @param name defines the name of the task
  62596. * @param meshesNames defines the list of mesh's names you want to load
  62597. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62598. * @param sceneFilename defines the filename of the scene to load from
  62599. */
  62600. constructor(
  62601. /**
  62602. * Defines the name of the task
  62603. */
  62604. name: string,
  62605. /**
  62606. * Defines the list of mesh's names you want to load
  62607. */
  62608. meshesNames: any,
  62609. /**
  62610. * Defines the root url to use as a base to load your meshes and associated resources
  62611. */
  62612. rootUrl: string,
  62613. /**
  62614. * Defines the filename of the scene to load from
  62615. */
  62616. sceneFilename: string);
  62617. /**
  62618. * Execute the current task
  62619. * @param scene defines the scene where you want your assets to be loaded
  62620. * @param onSuccess is a callback called when the task is successfully executed
  62621. * @param onError is a callback called if an error occurs
  62622. */
  62623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62624. }
  62625. /**
  62626. * Define a task used by AssetsManager to load text content
  62627. */
  62628. export class TextFileAssetTask extends AbstractAssetTask {
  62629. /**
  62630. * Defines the name of the task
  62631. */
  62632. name: string;
  62633. /**
  62634. * Defines the location of the file to load
  62635. */
  62636. url: string;
  62637. /**
  62638. * Gets the loaded text string
  62639. */
  62640. text: string;
  62641. /**
  62642. * Callback called when the task is successful
  62643. */
  62644. onSuccess: (task: TextFileAssetTask) => void;
  62645. /**
  62646. * Callback called when the task is successful
  62647. */
  62648. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62649. /**
  62650. * Creates a new TextFileAssetTask object
  62651. * @param name defines the name of the task
  62652. * @param url defines the location of the file to load
  62653. */
  62654. constructor(
  62655. /**
  62656. * Defines the name of the task
  62657. */
  62658. name: string,
  62659. /**
  62660. * Defines the location of the file to load
  62661. */
  62662. url: string);
  62663. /**
  62664. * Execute the current task
  62665. * @param scene defines the scene where you want your assets to be loaded
  62666. * @param onSuccess is a callback called when the task is successfully executed
  62667. * @param onError is a callback called if an error occurs
  62668. */
  62669. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62670. }
  62671. /**
  62672. * Define a task used by AssetsManager to load binary data
  62673. */
  62674. export class BinaryFileAssetTask extends AbstractAssetTask {
  62675. /**
  62676. * Defines the name of the task
  62677. */
  62678. name: string;
  62679. /**
  62680. * Defines the location of the file to load
  62681. */
  62682. url: string;
  62683. /**
  62684. * Gets the lodaded data (as an array buffer)
  62685. */
  62686. data: ArrayBuffer;
  62687. /**
  62688. * Callback called when the task is successful
  62689. */
  62690. onSuccess: (task: BinaryFileAssetTask) => void;
  62691. /**
  62692. * Callback called when the task is successful
  62693. */
  62694. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62695. /**
  62696. * Creates a new BinaryFileAssetTask object
  62697. * @param name defines the name of the new task
  62698. * @param url defines the location of the file to load
  62699. */
  62700. constructor(
  62701. /**
  62702. * Defines the name of the task
  62703. */
  62704. name: string,
  62705. /**
  62706. * Defines the location of the file to load
  62707. */
  62708. url: string);
  62709. /**
  62710. * Execute the current task
  62711. * @param scene defines the scene where you want your assets to be loaded
  62712. * @param onSuccess is a callback called when the task is successfully executed
  62713. * @param onError is a callback called if an error occurs
  62714. */
  62715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62716. }
  62717. /**
  62718. * Define a task used by AssetsManager to load images
  62719. */
  62720. export class ImageAssetTask extends AbstractAssetTask {
  62721. /**
  62722. * Defines the name of the task
  62723. */
  62724. name: string;
  62725. /**
  62726. * Defines the location of the image to load
  62727. */
  62728. url: string;
  62729. /**
  62730. * Gets the loaded images
  62731. */
  62732. image: HTMLImageElement;
  62733. /**
  62734. * Callback called when the task is successful
  62735. */
  62736. onSuccess: (task: ImageAssetTask) => void;
  62737. /**
  62738. * Callback called when the task is successful
  62739. */
  62740. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62741. /**
  62742. * Creates a new ImageAssetTask
  62743. * @param name defines the name of the task
  62744. * @param url defines the location of the image to load
  62745. */
  62746. constructor(
  62747. /**
  62748. * Defines the name of the task
  62749. */
  62750. name: string,
  62751. /**
  62752. * Defines the location of the image to load
  62753. */
  62754. url: string);
  62755. /**
  62756. * Execute the current task
  62757. * @param scene defines the scene where you want your assets to be loaded
  62758. * @param onSuccess is a callback called when the task is successfully executed
  62759. * @param onError is a callback called if an error occurs
  62760. */
  62761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62762. }
  62763. /**
  62764. * Defines the interface used by texture loading tasks
  62765. */
  62766. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62767. /**
  62768. * Gets the loaded texture
  62769. */
  62770. texture: TEX;
  62771. }
  62772. /**
  62773. * Define a task used by AssetsManager to load 2D textures
  62774. */
  62775. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62776. /**
  62777. * Defines the name of the task
  62778. */
  62779. name: string;
  62780. /**
  62781. * Defines the location of the file to load
  62782. */
  62783. url: string;
  62784. /**
  62785. * Defines if mipmap should not be generated (default is false)
  62786. */
  62787. noMipmap?: boolean | undefined;
  62788. /**
  62789. * Defines if texture must be inverted on Y axis (default is false)
  62790. */
  62791. invertY?: boolean | undefined;
  62792. /**
  62793. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62794. */
  62795. samplingMode: number;
  62796. /**
  62797. * Gets the loaded texture
  62798. */
  62799. texture: Texture;
  62800. /**
  62801. * Callback called when the task is successful
  62802. */
  62803. onSuccess: (task: TextureAssetTask) => void;
  62804. /**
  62805. * Callback called when the task is successful
  62806. */
  62807. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62808. /**
  62809. * Creates a new TextureAssetTask object
  62810. * @param name defines the name of the task
  62811. * @param url defines the location of the file to load
  62812. * @param noMipmap defines if mipmap should not be generated (default is false)
  62813. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62814. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62815. */
  62816. constructor(
  62817. /**
  62818. * Defines the name of the task
  62819. */
  62820. name: string,
  62821. /**
  62822. * Defines the location of the file to load
  62823. */
  62824. url: string,
  62825. /**
  62826. * Defines if mipmap should not be generated (default is false)
  62827. */
  62828. noMipmap?: boolean | undefined,
  62829. /**
  62830. * Defines if texture must be inverted on Y axis (default is false)
  62831. */
  62832. invertY?: boolean | undefined,
  62833. /**
  62834. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62835. */
  62836. samplingMode?: number);
  62837. /**
  62838. * Execute the current task
  62839. * @param scene defines the scene where you want your assets to be loaded
  62840. * @param onSuccess is a callback called when the task is successfully executed
  62841. * @param onError is a callback called if an error occurs
  62842. */
  62843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62844. }
  62845. /**
  62846. * Define a task used by AssetsManager to load cube textures
  62847. */
  62848. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62849. /**
  62850. * Defines the name of the task
  62851. */
  62852. name: string;
  62853. /**
  62854. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62855. */
  62856. url: string;
  62857. /**
  62858. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62859. */
  62860. extensions?: string[] | undefined;
  62861. /**
  62862. * Defines if mipmaps should not be generated (default is false)
  62863. */
  62864. noMipmap?: boolean | undefined;
  62865. /**
  62866. * Defines the explicit list of files (undefined by default)
  62867. */
  62868. files?: string[] | undefined;
  62869. /**
  62870. * Gets the loaded texture
  62871. */
  62872. texture: CubeTexture;
  62873. /**
  62874. * Callback called when the task is successful
  62875. */
  62876. onSuccess: (task: CubeTextureAssetTask) => void;
  62877. /**
  62878. * Callback called when the task is successful
  62879. */
  62880. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62881. /**
  62882. * Creates a new CubeTextureAssetTask
  62883. * @param name defines the name of the task
  62884. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62885. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62886. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62887. * @param files defines the explicit list of files (undefined by default)
  62888. */
  62889. constructor(
  62890. /**
  62891. * Defines the name of the task
  62892. */
  62893. name: string,
  62894. /**
  62895. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62896. */
  62897. url: string,
  62898. /**
  62899. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62900. */
  62901. extensions?: string[] | undefined,
  62902. /**
  62903. * Defines if mipmaps should not be generated (default is false)
  62904. */
  62905. noMipmap?: boolean | undefined,
  62906. /**
  62907. * Defines the explicit list of files (undefined by default)
  62908. */
  62909. files?: string[] | undefined);
  62910. /**
  62911. * Execute the current task
  62912. * @param scene defines the scene where you want your assets to be loaded
  62913. * @param onSuccess is a callback called when the task is successfully executed
  62914. * @param onError is a callback called if an error occurs
  62915. */
  62916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62917. }
  62918. /**
  62919. * Define a task used by AssetsManager to load HDR cube textures
  62920. */
  62921. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62922. /**
  62923. * Defines the name of the task
  62924. */
  62925. name: string;
  62926. /**
  62927. * Defines the location of the file to load
  62928. */
  62929. url: string;
  62930. /**
  62931. * Defines the desired size (the more it increases the longer the generation will be)
  62932. */
  62933. size: number;
  62934. /**
  62935. * Defines if mipmaps should not be generated (default is false)
  62936. */
  62937. noMipmap: boolean;
  62938. /**
  62939. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62940. */
  62941. generateHarmonics: boolean;
  62942. /**
  62943. * 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)
  62944. */
  62945. gammaSpace: boolean;
  62946. /**
  62947. * Internal Use Only
  62948. */
  62949. reserved: boolean;
  62950. /**
  62951. * Gets the loaded texture
  62952. */
  62953. texture: HDRCubeTexture;
  62954. /**
  62955. * Callback called when the task is successful
  62956. */
  62957. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62958. /**
  62959. * Callback called when the task is successful
  62960. */
  62961. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62962. /**
  62963. * Creates a new HDRCubeTextureAssetTask object
  62964. * @param name defines the name of the task
  62965. * @param url defines the location of the file to load
  62966. * @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.
  62967. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62968. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62969. * @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)
  62970. * @param reserved Internal use only
  62971. */
  62972. constructor(
  62973. /**
  62974. * Defines the name of the task
  62975. */
  62976. name: string,
  62977. /**
  62978. * Defines the location of the file to load
  62979. */
  62980. url: string,
  62981. /**
  62982. * Defines the desired size (the more it increases the longer the generation will be)
  62983. */
  62984. size: number,
  62985. /**
  62986. * Defines if mipmaps should not be generated (default is false)
  62987. */
  62988. noMipmap?: boolean,
  62989. /**
  62990. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62991. */
  62992. generateHarmonics?: boolean,
  62993. /**
  62994. * 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)
  62995. */
  62996. gammaSpace?: boolean,
  62997. /**
  62998. * Internal Use Only
  62999. */
  63000. reserved?: boolean);
  63001. /**
  63002. * Execute the current task
  63003. * @param scene defines the scene where you want your assets to be loaded
  63004. * @param onSuccess is a callback called when the task is successfully executed
  63005. * @param onError is a callback called if an error occurs
  63006. */
  63007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63008. }
  63009. /**
  63010. * Define a task used by AssetsManager to load Equirectangular cube textures
  63011. */
  63012. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63013. /**
  63014. * Defines the name of the task
  63015. */
  63016. name: string;
  63017. /**
  63018. * Defines the location of the file to load
  63019. */
  63020. url: string;
  63021. /**
  63022. * Defines the desired size (the more it increases the longer the generation will be)
  63023. */
  63024. size: number;
  63025. /**
  63026. * Defines if mipmaps should not be generated (default is false)
  63027. */
  63028. noMipmap: boolean;
  63029. /**
  63030. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63031. * but the standard material would require them in Gamma space) (default is true)
  63032. */
  63033. gammaSpace: boolean;
  63034. /**
  63035. * Gets the loaded texture
  63036. */
  63037. texture: EquiRectangularCubeTexture;
  63038. /**
  63039. * Callback called when the task is successful
  63040. */
  63041. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63042. /**
  63043. * Callback called when the task is successful
  63044. */
  63045. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63046. /**
  63047. * Creates a new EquiRectangularCubeTextureAssetTask object
  63048. * @param name defines the name of the task
  63049. * @param url defines the location of the file to load
  63050. * @param size defines the desired size (the more it increases the longer the generation will be)
  63051. * If the size is omitted this implies you are using a preprocessed cubemap.
  63052. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63053. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63054. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63055. * (default is true)
  63056. */
  63057. constructor(
  63058. /**
  63059. * Defines the name of the task
  63060. */
  63061. name: string,
  63062. /**
  63063. * Defines the location of the file to load
  63064. */
  63065. url: string,
  63066. /**
  63067. * Defines the desired size (the more it increases the longer the generation will be)
  63068. */
  63069. size: number,
  63070. /**
  63071. * Defines if mipmaps should not be generated (default is false)
  63072. */
  63073. noMipmap?: boolean,
  63074. /**
  63075. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63076. * but the standard material would require them in Gamma space) (default is true)
  63077. */
  63078. gammaSpace?: boolean);
  63079. /**
  63080. * Execute the current task
  63081. * @param scene defines the scene where you want your assets to be loaded
  63082. * @param onSuccess is a callback called when the task is successfully executed
  63083. * @param onError is a callback called if an error occurs
  63084. */
  63085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63086. }
  63087. /**
  63088. * This class can be used to easily import assets into a scene
  63089. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63090. */
  63091. export class AssetsManager {
  63092. private _scene;
  63093. private _isLoading;
  63094. protected _tasks: AbstractAssetTask[];
  63095. protected _waitingTasksCount: number;
  63096. protected _totalTasksCount: number;
  63097. /**
  63098. * Callback called when all tasks are processed
  63099. */
  63100. onFinish: (tasks: AbstractAssetTask[]) => void;
  63101. /**
  63102. * Callback called when a task is successful
  63103. */
  63104. onTaskSuccess: (task: AbstractAssetTask) => void;
  63105. /**
  63106. * Callback called when a task had an error
  63107. */
  63108. onTaskError: (task: AbstractAssetTask) => void;
  63109. /**
  63110. * Callback called when a task is done (whatever the result is)
  63111. */
  63112. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63113. /**
  63114. * Observable called when all tasks are processed
  63115. */
  63116. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63117. /**
  63118. * Observable called when a task had an error
  63119. */
  63120. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63121. /**
  63122. * Observable called when all tasks were executed
  63123. */
  63124. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63125. /**
  63126. * Observable called when a task is done (whatever the result is)
  63127. */
  63128. onProgressObservable: Observable<IAssetsProgressEvent>;
  63129. /**
  63130. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63132. */
  63133. useDefaultLoadingScreen: boolean;
  63134. /**
  63135. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63136. * when all assets have been downloaded.
  63137. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63138. */
  63139. autoHideLoadingUI: boolean;
  63140. /**
  63141. * Creates a new AssetsManager
  63142. * @param scene defines the scene to work on
  63143. */
  63144. constructor(scene: Scene);
  63145. /**
  63146. * Add a MeshAssetTask to the list of active tasks
  63147. * @param taskName defines the name of the new task
  63148. * @param meshesNames defines the name of meshes to load
  63149. * @param rootUrl defines the root url to use to locate files
  63150. * @param sceneFilename defines the filename of the scene file
  63151. * @returns a new MeshAssetTask object
  63152. */
  63153. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63154. /**
  63155. * Add a TextFileAssetTask to the list of active tasks
  63156. * @param taskName defines the name of the new task
  63157. * @param url defines the url of the file to load
  63158. * @returns a new TextFileAssetTask object
  63159. */
  63160. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63161. /**
  63162. * Add a BinaryFileAssetTask to the list of active tasks
  63163. * @param taskName defines the name of the new task
  63164. * @param url defines the url of the file to load
  63165. * @returns a new BinaryFileAssetTask object
  63166. */
  63167. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63168. /**
  63169. * Add a ImageAssetTask to the list of active tasks
  63170. * @param taskName defines the name of the new task
  63171. * @param url defines the url of the file to load
  63172. * @returns a new ImageAssetTask object
  63173. */
  63174. addImageTask(taskName: string, url: string): ImageAssetTask;
  63175. /**
  63176. * Add a TextureAssetTask to the list of active tasks
  63177. * @param taskName defines the name of the new task
  63178. * @param url defines the url of the file to load
  63179. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63180. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63181. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63182. * @returns a new TextureAssetTask object
  63183. */
  63184. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63185. /**
  63186. * Add a CubeTextureAssetTask to the list of active tasks
  63187. * @param taskName defines the name of the new task
  63188. * @param url defines the url of the file to load
  63189. * @param extensions defines the extension to use to load the cube map (can be null)
  63190. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63191. * @param files defines the list of files to load (can be null)
  63192. * @returns a new CubeTextureAssetTask object
  63193. */
  63194. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63195. /**
  63196. *
  63197. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63198. * @param taskName defines the name of the new task
  63199. * @param url defines the url of the file to load
  63200. * @param size defines the size you want for the cubemap (can be null)
  63201. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63202. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63203. * @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)
  63204. * @param reserved Internal use only
  63205. * @returns a new HDRCubeTextureAssetTask object
  63206. */
  63207. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63208. /**
  63209. *
  63210. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63211. * @param taskName defines the name of the new task
  63212. * @param url defines the url of the file to load
  63213. * @param size defines the size you want for the cubemap (can be null)
  63214. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63215. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63216. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63217. * @returns a new EquiRectangularCubeTextureAssetTask object
  63218. */
  63219. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63220. /**
  63221. * Remove a task from the assets manager.
  63222. * @param task the task to remove
  63223. */
  63224. removeTask(task: AbstractAssetTask): void;
  63225. private _decreaseWaitingTasksCount;
  63226. private _runTask;
  63227. /**
  63228. * Reset the AssetsManager and remove all tasks
  63229. * @return the current instance of the AssetsManager
  63230. */
  63231. reset(): AssetsManager;
  63232. /**
  63233. * Start the loading process
  63234. * @return the current instance of the AssetsManager
  63235. */
  63236. load(): AssetsManager;
  63237. /**
  63238. * Start the loading process as an async operation
  63239. * @return a promise returning the list of failed tasks
  63240. */
  63241. loadAsync(): Promise<void>;
  63242. }
  63243. }
  63244. declare module BABYLON {
  63245. /**
  63246. * Wrapper class for promise with external resolve and reject.
  63247. */
  63248. export class Deferred<T> {
  63249. /**
  63250. * The promise associated with this deferred object.
  63251. */
  63252. readonly promise: Promise<T>;
  63253. private _resolve;
  63254. private _reject;
  63255. /**
  63256. * The resolve method of the promise associated with this deferred object.
  63257. */
  63258. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63259. /**
  63260. * The reject method of the promise associated with this deferred object.
  63261. */
  63262. readonly reject: (reason?: any) => void;
  63263. /**
  63264. * Constructor for this deferred object.
  63265. */
  63266. constructor();
  63267. }
  63268. }
  63269. declare module BABYLON {
  63270. /**
  63271. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63272. */
  63273. export class MeshExploder {
  63274. private _centerMesh;
  63275. private _meshes;
  63276. private _meshesOrigins;
  63277. private _toCenterVectors;
  63278. private _scaledDirection;
  63279. private _newPosition;
  63280. private _centerPosition;
  63281. /**
  63282. * Explodes meshes from a center mesh.
  63283. * @param meshes The meshes to explode.
  63284. * @param centerMesh The mesh to be center of explosion.
  63285. */
  63286. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63287. private _setCenterMesh;
  63288. /**
  63289. * Get class name
  63290. * @returns "MeshExploder"
  63291. */
  63292. getClassName(): string;
  63293. /**
  63294. * "Exploded meshes"
  63295. * @returns Array of meshes with the centerMesh at index 0.
  63296. */
  63297. getMeshes(): Array<Mesh>;
  63298. /**
  63299. * Explodes meshes giving a specific direction
  63300. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63301. */
  63302. explode(direction?: number): void;
  63303. }
  63304. }
  63305. declare module BABYLON {
  63306. /**
  63307. * Class used to help managing file picking and drag'n'drop
  63308. */
  63309. export class FilesInput {
  63310. /**
  63311. * List of files ready to be loaded
  63312. */
  63313. static readonly FilesToLoad: {
  63314. [key: string]: File;
  63315. };
  63316. /**
  63317. * Callback called when a file is processed
  63318. */
  63319. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63320. private _engine;
  63321. private _currentScene;
  63322. private _sceneLoadedCallback;
  63323. private _progressCallback;
  63324. private _additionalRenderLoopLogicCallback;
  63325. private _textureLoadingCallback;
  63326. private _startingProcessingFilesCallback;
  63327. private _onReloadCallback;
  63328. private _errorCallback;
  63329. private _elementToMonitor;
  63330. private _sceneFileToLoad;
  63331. private _filesToLoad;
  63332. /**
  63333. * Creates a new FilesInput
  63334. * @param engine defines the rendering engine
  63335. * @param scene defines the hosting scene
  63336. * @param sceneLoadedCallback callback called when scene is loaded
  63337. * @param progressCallback callback called to track progress
  63338. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63339. * @param textureLoadingCallback callback called when a texture is loading
  63340. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63341. * @param onReloadCallback callback called when a reload is requested
  63342. * @param errorCallback callback call if an error occurs
  63343. */
  63344. 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);
  63345. private _dragEnterHandler;
  63346. private _dragOverHandler;
  63347. private _dropHandler;
  63348. /**
  63349. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63350. * @param elementToMonitor defines the DOM element to track
  63351. */
  63352. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63353. /**
  63354. * Release all associated resources
  63355. */
  63356. dispose(): void;
  63357. private renderFunction;
  63358. private drag;
  63359. private drop;
  63360. private _traverseFolder;
  63361. private _processFiles;
  63362. /**
  63363. * Load files from a drop event
  63364. * @param event defines the drop event to use as source
  63365. */
  63366. loadFiles(event: any): void;
  63367. private _processReload;
  63368. /**
  63369. * Reload the current scene from the loaded files
  63370. */
  63371. reload(): void;
  63372. }
  63373. }
  63374. declare module BABYLON {
  63375. /**
  63376. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63378. */
  63379. export class SceneOptimization {
  63380. /**
  63381. * Defines the priority of this optimization (0 by default which means first in the list)
  63382. */
  63383. priority: number;
  63384. /**
  63385. * Gets a string describing the action executed by the current optimization
  63386. * @returns description string
  63387. */
  63388. getDescription(): string;
  63389. /**
  63390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63391. * @param scene defines the current scene where to apply this optimization
  63392. * @param optimizer defines the current optimizer
  63393. * @returns true if everything that can be done was applied
  63394. */
  63395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63396. /**
  63397. * Creates the SceneOptimization object
  63398. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63399. * @param desc defines the description associated with the optimization
  63400. */
  63401. constructor(
  63402. /**
  63403. * Defines the priority of this optimization (0 by default which means first in the list)
  63404. */
  63405. priority?: number);
  63406. }
  63407. /**
  63408. * Defines an optimization used to reduce the size of render target textures
  63409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63410. */
  63411. export class TextureOptimization extends SceneOptimization {
  63412. /**
  63413. * Defines the priority of this optimization (0 by default which means first in the list)
  63414. */
  63415. priority: number;
  63416. /**
  63417. * 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
  63418. */
  63419. maximumSize: number;
  63420. /**
  63421. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63422. */
  63423. step: number;
  63424. /**
  63425. * Gets a string describing the action executed by the current optimization
  63426. * @returns description string
  63427. */
  63428. getDescription(): string;
  63429. /**
  63430. * Creates the TextureOptimization object
  63431. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63432. * @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
  63433. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63434. */
  63435. constructor(
  63436. /**
  63437. * Defines the priority of this optimization (0 by default which means first in the list)
  63438. */
  63439. priority?: number,
  63440. /**
  63441. * 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
  63442. */
  63443. maximumSize?: number,
  63444. /**
  63445. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63446. */
  63447. step?: number);
  63448. /**
  63449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63450. * @param scene defines the current scene where to apply this optimization
  63451. * @param optimizer defines the current optimizer
  63452. * @returns true if everything that can be done was applied
  63453. */
  63454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63455. }
  63456. /**
  63457. * Defines an optimization used to increase or decrease the rendering resolution
  63458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63459. */
  63460. export class HardwareScalingOptimization extends SceneOptimization {
  63461. /**
  63462. * Defines the priority of this optimization (0 by default which means first in the list)
  63463. */
  63464. priority: number;
  63465. /**
  63466. * Defines the maximum scale to use (2 by default)
  63467. */
  63468. maximumScale: number;
  63469. /**
  63470. * Defines the step to use between two passes (0.5 by default)
  63471. */
  63472. step: number;
  63473. private _currentScale;
  63474. private _directionOffset;
  63475. /**
  63476. * Gets a string describing the action executed by the current optimization
  63477. * @return description string
  63478. */
  63479. getDescription(): string;
  63480. /**
  63481. * Creates the HardwareScalingOptimization object
  63482. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63483. * @param maximumScale defines the maximum scale to use (2 by default)
  63484. * @param step defines the step to use between two passes (0.5 by default)
  63485. */
  63486. constructor(
  63487. /**
  63488. * Defines the priority of this optimization (0 by default which means first in the list)
  63489. */
  63490. priority?: number,
  63491. /**
  63492. * Defines the maximum scale to use (2 by default)
  63493. */
  63494. maximumScale?: number,
  63495. /**
  63496. * Defines the step to use between two passes (0.5 by default)
  63497. */
  63498. step?: number);
  63499. /**
  63500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63501. * @param scene defines the current scene where to apply this optimization
  63502. * @param optimizer defines the current optimizer
  63503. * @returns true if everything that can be done was applied
  63504. */
  63505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63506. }
  63507. /**
  63508. * Defines an optimization used to remove shadows
  63509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63510. */
  63511. export class ShadowsOptimization extends SceneOptimization {
  63512. /**
  63513. * Gets a string describing the action executed by the current optimization
  63514. * @return description string
  63515. */
  63516. getDescription(): string;
  63517. /**
  63518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63519. * @param scene defines the current scene where to apply this optimization
  63520. * @param optimizer defines the current optimizer
  63521. * @returns true if everything that can be done was applied
  63522. */
  63523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63524. }
  63525. /**
  63526. * Defines an optimization used to turn post-processes off
  63527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63528. */
  63529. export class PostProcessesOptimization extends SceneOptimization {
  63530. /**
  63531. * Gets a string describing the action executed by the current optimization
  63532. * @return description string
  63533. */
  63534. getDescription(): string;
  63535. /**
  63536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63537. * @param scene defines the current scene where to apply this optimization
  63538. * @param optimizer defines the current optimizer
  63539. * @returns true if everything that can be done was applied
  63540. */
  63541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63542. }
  63543. /**
  63544. * Defines an optimization used to turn lens flares off
  63545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63546. */
  63547. export class LensFlaresOptimization extends SceneOptimization {
  63548. /**
  63549. * Gets a string describing the action executed by the current optimization
  63550. * @return description string
  63551. */
  63552. getDescription(): string;
  63553. /**
  63554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63555. * @param scene defines the current scene where to apply this optimization
  63556. * @param optimizer defines the current optimizer
  63557. * @returns true if everything that can be done was applied
  63558. */
  63559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63560. }
  63561. /**
  63562. * Defines an optimization based on user defined callback.
  63563. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63564. */
  63565. export class CustomOptimization extends SceneOptimization {
  63566. /**
  63567. * Callback called to apply the custom optimization.
  63568. */
  63569. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63570. /**
  63571. * Callback called to get custom description
  63572. */
  63573. onGetDescription: () => string;
  63574. /**
  63575. * Gets a string describing the action executed by the current optimization
  63576. * @returns description string
  63577. */
  63578. getDescription(): string;
  63579. /**
  63580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63581. * @param scene defines the current scene where to apply this optimization
  63582. * @param optimizer defines the current optimizer
  63583. * @returns true if everything that can be done was applied
  63584. */
  63585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63586. }
  63587. /**
  63588. * Defines an optimization used to turn particles off
  63589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63590. */
  63591. export class ParticlesOptimization extends SceneOptimization {
  63592. /**
  63593. * Gets a string describing the action executed by the current optimization
  63594. * @return description string
  63595. */
  63596. getDescription(): string;
  63597. /**
  63598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63599. * @param scene defines the current scene where to apply this optimization
  63600. * @param optimizer defines the current optimizer
  63601. * @returns true if everything that can be done was applied
  63602. */
  63603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63604. }
  63605. /**
  63606. * Defines an optimization used to turn render targets off
  63607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63608. */
  63609. export class RenderTargetsOptimization extends SceneOptimization {
  63610. /**
  63611. * Gets a string describing the action executed by the current optimization
  63612. * @return description string
  63613. */
  63614. getDescription(): string;
  63615. /**
  63616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63617. * @param scene defines the current scene where to apply this optimization
  63618. * @param optimizer defines the current optimizer
  63619. * @returns true if everything that can be done was applied
  63620. */
  63621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63622. }
  63623. /**
  63624. * Defines an optimization used to merge meshes with compatible materials
  63625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63626. */
  63627. export class MergeMeshesOptimization extends SceneOptimization {
  63628. private static _UpdateSelectionTree;
  63629. /**
  63630. * Gets or sets a boolean which defines if optimization octree has to be updated
  63631. */
  63632. /**
  63633. * Gets or sets a boolean which defines if optimization octree has to be updated
  63634. */
  63635. static UpdateSelectionTree: boolean;
  63636. /**
  63637. * Gets a string describing the action executed by the current optimization
  63638. * @return description string
  63639. */
  63640. getDescription(): string;
  63641. private _canBeMerged;
  63642. /**
  63643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63644. * @param scene defines the current scene where to apply this optimization
  63645. * @param optimizer defines the current optimizer
  63646. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63647. * @returns true if everything that can be done was applied
  63648. */
  63649. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63650. }
  63651. /**
  63652. * Defines a list of options used by SceneOptimizer
  63653. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63654. */
  63655. export class SceneOptimizerOptions {
  63656. /**
  63657. * Defines the target frame rate to reach (60 by default)
  63658. */
  63659. targetFrameRate: number;
  63660. /**
  63661. * Defines the interval between two checkes (2000ms by default)
  63662. */
  63663. trackerDuration: number;
  63664. /**
  63665. * Gets the list of optimizations to apply
  63666. */
  63667. optimizations: SceneOptimization[];
  63668. /**
  63669. * Creates a new list of options used by SceneOptimizer
  63670. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63671. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63672. */
  63673. constructor(
  63674. /**
  63675. * Defines the target frame rate to reach (60 by default)
  63676. */
  63677. targetFrameRate?: number,
  63678. /**
  63679. * Defines the interval between two checkes (2000ms by default)
  63680. */
  63681. trackerDuration?: number);
  63682. /**
  63683. * Add a new optimization
  63684. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63685. * @returns the current SceneOptimizerOptions
  63686. */
  63687. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63688. /**
  63689. * Add a new custom optimization
  63690. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63691. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63692. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63693. * @returns the current SceneOptimizerOptions
  63694. */
  63695. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63696. /**
  63697. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63698. * @param targetFrameRate defines the target frame rate (60 by default)
  63699. * @returns a SceneOptimizerOptions object
  63700. */
  63701. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63702. /**
  63703. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63704. * @param targetFrameRate defines the target frame rate (60 by default)
  63705. * @returns a SceneOptimizerOptions object
  63706. */
  63707. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63708. /**
  63709. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63710. * @param targetFrameRate defines the target frame rate (60 by default)
  63711. * @returns a SceneOptimizerOptions object
  63712. */
  63713. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63714. }
  63715. /**
  63716. * Class used to run optimizations in order to reach a target frame rate
  63717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63718. */
  63719. export class SceneOptimizer implements IDisposable {
  63720. private _isRunning;
  63721. private _options;
  63722. private _scene;
  63723. private _currentPriorityLevel;
  63724. private _targetFrameRate;
  63725. private _trackerDuration;
  63726. private _currentFrameRate;
  63727. private _sceneDisposeObserver;
  63728. private _improvementMode;
  63729. /**
  63730. * Defines an observable called when the optimizer reaches the target frame rate
  63731. */
  63732. onSuccessObservable: Observable<SceneOptimizer>;
  63733. /**
  63734. * Defines an observable called when the optimizer enables an optimization
  63735. */
  63736. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63737. /**
  63738. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63739. */
  63740. onFailureObservable: Observable<SceneOptimizer>;
  63741. /**
  63742. * Gets a boolean indicating if the optimizer is in improvement mode
  63743. */
  63744. readonly isInImprovementMode: boolean;
  63745. /**
  63746. * Gets the current priority level (0 at start)
  63747. */
  63748. readonly currentPriorityLevel: number;
  63749. /**
  63750. * Gets the current frame rate checked by the SceneOptimizer
  63751. */
  63752. readonly currentFrameRate: number;
  63753. /**
  63754. * Gets or sets the current target frame rate (60 by default)
  63755. */
  63756. /**
  63757. * Gets or sets the current target frame rate (60 by default)
  63758. */
  63759. targetFrameRate: number;
  63760. /**
  63761. * Gets or sets the current interval between two checks (every 2000ms by default)
  63762. */
  63763. /**
  63764. * Gets or sets the current interval between two checks (every 2000ms by default)
  63765. */
  63766. trackerDuration: number;
  63767. /**
  63768. * Gets the list of active optimizations
  63769. */
  63770. readonly optimizations: SceneOptimization[];
  63771. /**
  63772. * Creates a new SceneOptimizer
  63773. * @param scene defines the scene to work on
  63774. * @param options defines the options to use with the SceneOptimizer
  63775. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63776. * @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)
  63777. */
  63778. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63779. /**
  63780. * Stops the current optimizer
  63781. */
  63782. stop(): void;
  63783. /**
  63784. * Reset the optimizer to initial step (current priority level = 0)
  63785. */
  63786. reset(): void;
  63787. /**
  63788. * Start the optimizer. By default it will try to reach a specific framerate
  63789. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63790. */
  63791. start(): void;
  63792. private _checkCurrentState;
  63793. /**
  63794. * Release all resources
  63795. */
  63796. dispose(): void;
  63797. /**
  63798. * Helper function to create a SceneOptimizer with one single line of code
  63799. * @param scene defines the scene to work on
  63800. * @param options defines the options to use with the SceneOptimizer
  63801. * @param onSuccess defines a callback to call on success
  63802. * @param onFailure defines a callback to call on failure
  63803. * @returns the new SceneOptimizer object
  63804. */
  63805. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63806. }
  63807. }
  63808. declare module BABYLON {
  63809. /**
  63810. * Class used to serialize a scene into a string
  63811. */
  63812. export class SceneSerializer {
  63813. /**
  63814. * Clear cache used by a previous serialization
  63815. */
  63816. static ClearCache(): void;
  63817. /**
  63818. * Serialize a scene into a JSON compatible object
  63819. * @param scene defines the scene to serialize
  63820. * @returns a JSON compatible object
  63821. */
  63822. static Serialize(scene: Scene): any;
  63823. /**
  63824. * Serialize a mesh into a JSON compatible object
  63825. * @param toSerialize defines the mesh to serialize
  63826. * @param withParents defines if parents must be serialized as well
  63827. * @param withChildren defines if children must be serialized as well
  63828. * @returns a JSON compatible object
  63829. */
  63830. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63831. }
  63832. }
  63833. declare module BABYLON {
  63834. /**
  63835. * Class used to host texture specific utilities
  63836. */
  63837. export class TextureTools {
  63838. /**
  63839. * Uses the GPU to create a copy texture rescaled at a given size
  63840. * @param texture Texture to copy from
  63841. * @param width defines the desired width
  63842. * @param height defines the desired height
  63843. * @param useBilinearMode defines if bilinear mode has to be used
  63844. * @return the generated texture
  63845. */
  63846. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * This represents the different options available for the video capture.
  63852. */
  63853. export interface VideoRecorderOptions {
  63854. /** Defines the mime type of the video. */
  63855. mimeType: string;
  63856. /** Defines the FPS the video should be recorded at. */
  63857. fps: number;
  63858. /** Defines the chunk size for the recording data. */
  63859. recordChunckSize: number;
  63860. /** The audio tracks to attach to the recording. */
  63861. audioTracks?: MediaStreamTrack[];
  63862. }
  63863. /**
  63864. * This can help with recording videos from BabylonJS.
  63865. * This is based on the available WebRTC functionalities of the browser.
  63866. *
  63867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63868. */
  63869. export class VideoRecorder {
  63870. private static readonly _defaultOptions;
  63871. /**
  63872. * Returns whether or not the VideoRecorder is available in your browser.
  63873. * @param engine Defines the Babylon Engine.
  63874. * @returns true if supported otherwise false.
  63875. */
  63876. static IsSupported(engine: Engine): boolean;
  63877. private readonly _options;
  63878. private _canvas;
  63879. private _mediaRecorder;
  63880. private _recordedChunks;
  63881. private _fileName;
  63882. private _resolve;
  63883. private _reject;
  63884. /**
  63885. * True when a recording is already in progress.
  63886. */
  63887. readonly isRecording: boolean;
  63888. /**
  63889. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63890. * @param engine Defines the BabylonJS Engine you wish to record.
  63891. * @param options Defines options that can be used to customize the capture.
  63892. */
  63893. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63894. /**
  63895. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63896. */
  63897. stopRecording(): void;
  63898. /**
  63899. * Starts recording the canvas for a max duration specified in parameters.
  63900. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63901. * If null no automatic download will start and you can rely on the promise to get the data back.
  63902. * @param maxDuration Defines the maximum recording time in seconds.
  63903. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63904. * @return A promise callback at the end of the recording with the video data in Blob.
  63905. */
  63906. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63907. /**
  63908. * Releases internal resources used during the recording.
  63909. */
  63910. dispose(): void;
  63911. private _handleDataAvailable;
  63912. private _handleError;
  63913. private _handleStop;
  63914. }
  63915. }
  63916. declare module BABYLON {
  63917. /**
  63918. * Class containing a set of static utilities functions for screenshots
  63919. */
  63920. export class ScreenshotTools {
  63921. /**
  63922. * Captures a screenshot of the current rendering
  63923. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63924. * @param engine defines the rendering engine
  63925. * @param camera defines the source camera
  63926. * @param size This parameter can be set to a single number or to an object with the
  63927. * following (optional) properties: precision, width, height. If a single number is passed,
  63928. * it will be used for both width and height. If an object is passed, the screenshot size
  63929. * will be derived from the parameters. The precision property is a multiplier allowing
  63930. * rendering at a higher or lower resolution
  63931. * @param successCallback defines the callback receives a single parameter which contains the
  63932. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63933. * src parameter of an <img> to display it
  63934. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63935. * Check your browser for supported MIME types
  63936. */
  63937. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63938. /**
  63939. * Captures a screenshot of the current rendering
  63940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63941. * @param engine defines the rendering engine
  63942. * @param camera defines the source camera
  63943. * @param size This parameter can be set to a single number or to an object with the
  63944. * following (optional) properties: precision, width, height. If a single number is passed,
  63945. * it will be used for both width and height. If an object is passed, the screenshot size
  63946. * will be derived from the parameters. The precision property is a multiplier allowing
  63947. * rendering at a higher or lower resolution
  63948. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63949. * Check your browser for supported MIME types
  63950. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63951. * to the src parameter of an <img> to display it
  63952. */
  63953. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63954. /**
  63955. * Generates an image screenshot from the specified camera.
  63956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63957. * @param engine The engine to use for rendering
  63958. * @param camera The camera to use for rendering
  63959. * @param size This parameter can be set to a single number or to an object with the
  63960. * following (optional) properties: precision, width, height. If a single number is passed,
  63961. * it will be used for both width and height. If an object is passed, the screenshot size
  63962. * will be derived from the parameters. The precision property is a multiplier allowing
  63963. * rendering at a higher or lower resolution
  63964. * @param successCallback The callback receives a single parameter which contains the
  63965. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63966. * src parameter of an <img> to display it
  63967. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63968. * Check your browser for supported MIME types
  63969. * @param samples Texture samples (default: 1)
  63970. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63971. * @param fileName A name for for the downloaded file.
  63972. */
  63973. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63974. /**
  63975. * Generates an image screenshot from the specified camera.
  63976. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63977. * @param engine The engine to use for rendering
  63978. * @param camera The camera to use for rendering
  63979. * @param size This parameter can be set to a single number or to an object with the
  63980. * following (optional) properties: precision, width, height. If a single number is passed,
  63981. * it will be used for both width and height. If an object is passed, the screenshot size
  63982. * will be derived from the parameters. The precision property is a multiplier allowing
  63983. * rendering at a higher or lower resolution
  63984. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63985. * Check your browser for supported MIME types
  63986. * @param samples Texture samples (default: 1)
  63987. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63988. * @param fileName A name for for the downloaded file.
  63989. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63990. * to the src parameter of an <img> to display it
  63991. */
  63992. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63993. /**
  63994. * Gets height and width for screenshot size
  63995. * @private
  63996. */
  63997. private static _getScreenshotSize;
  63998. }
  63999. }
  64000. declare module BABYLON {
  64001. /**
  64002. * Interface for a data buffer
  64003. */
  64004. export interface IDataBuffer {
  64005. /**
  64006. * Reads bytes from the data buffer.
  64007. * @param byteOffset The byte offset to read
  64008. * @param byteLength The byte length to read
  64009. * @returns A promise that resolves when the bytes are read
  64010. */
  64011. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64012. /**
  64013. * The byte length of the buffer.
  64014. */
  64015. readonly byteLength: number;
  64016. }
  64017. /**
  64018. * Utility class for reading from a data buffer
  64019. */
  64020. export class DataReader {
  64021. /**
  64022. * The data buffer associated with this data reader.
  64023. */
  64024. readonly buffer: IDataBuffer;
  64025. /**
  64026. * The current byte offset from the beginning of the data buffer.
  64027. */
  64028. byteOffset: number;
  64029. private _dataView;
  64030. private _dataByteOffset;
  64031. /**
  64032. * Constructor
  64033. * @param buffer The buffer to read
  64034. */
  64035. constructor(buffer: IDataBuffer);
  64036. /**
  64037. * Loads the given byte length.
  64038. * @param byteLength The byte length to load
  64039. * @returns A promise that resolves when the load is complete
  64040. */
  64041. loadAsync(byteLength: number): Promise<void>;
  64042. /**
  64043. * Read a unsigned 32-bit integer from the currently loaded data range.
  64044. * @returns The 32-bit integer read
  64045. */
  64046. readUint32(): number;
  64047. /**
  64048. * Read a byte array from the currently loaded data range.
  64049. * @param byteLength The byte length to read
  64050. * @returns The byte array read
  64051. */
  64052. readUint8Array(byteLength: number): Uint8Array;
  64053. /**
  64054. * Read a string from the currently loaded data range.
  64055. * @param byteLength The byte length to read
  64056. * @returns The string read
  64057. */
  64058. readString(byteLength: number): string;
  64059. /**
  64060. * Skips the given byte length the currently loaded data range.
  64061. * @param byteLength The byte length to skip
  64062. */
  64063. skipBytes(byteLength: number): void;
  64064. }
  64065. }
  64066. declare module BABYLON {
  64067. /**
  64068. * A cursor which tracks a point on a path
  64069. */
  64070. export class PathCursor {
  64071. private path;
  64072. /**
  64073. * Stores path cursor callbacks for when an onchange event is triggered
  64074. */
  64075. private _onchange;
  64076. /**
  64077. * The value of the path cursor
  64078. */
  64079. value: number;
  64080. /**
  64081. * The animation array of the path cursor
  64082. */
  64083. animations: Animation[];
  64084. /**
  64085. * Initializes the path cursor
  64086. * @param path The path to track
  64087. */
  64088. constructor(path: Path2);
  64089. /**
  64090. * Gets the cursor point on the path
  64091. * @returns A point on the path cursor at the cursor location
  64092. */
  64093. getPoint(): Vector3;
  64094. /**
  64095. * Moves the cursor ahead by the step amount
  64096. * @param step The amount to move the cursor forward
  64097. * @returns This path cursor
  64098. */
  64099. moveAhead(step?: number): PathCursor;
  64100. /**
  64101. * Moves the cursor behind by the step amount
  64102. * @param step The amount to move the cursor back
  64103. * @returns This path cursor
  64104. */
  64105. moveBack(step?: number): PathCursor;
  64106. /**
  64107. * Moves the cursor by the step amount
  64108. * If the step amount is greater than one, an exception is thrown
  64109. * @param step The amount to move the cursor
  64110. * @returns This path cursor
  64111. */
  64112. move(step: number): PathCursor;
  64113. /**
  64114. * Ensures that the value is limited between zero and one
  64115. * @returns This path cursor
  64116. */
  64117. private ensureLimits;
  64118. /**
  64119. * Runs onchange callbacks on change (used by the animation engine)
  64120. * @returns This path cursor
  64121. */
  64122. private raiseOnChange;
  64123. /**
  64124. * Executes a function on change
  64125. * @param f A path cursor onchange callback
  64126. * @returns This path cursor
  64127. */
  64128. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64129. }
  64130. }
  64131. declare module BABYLON {
  64132. /** @hidden */
  64133. export var blurPixelShader: {
  64134. name: string;
  64135. shader: string;
  64136. };
  64137. }
  64138. declare module BABYLON {
  64139. /** @hidden */
  64140. export var pointCloudVertexDeclaration: {
  64141. name: string;
  64142. shader: string;
  64143. };
  64144. }
  64145. // Mixins
  64146. interface Window {
  64147. mozIndexedDB: IDBFactory;
  64148. webkitIndexedDB: IDBFactory;
  64149. msIndexedDB: IDBFactory;
  64150. webkitURL: typeof URL;
  64151. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64152. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64153. WebGLRenderingContext: WebGLRenderingContext;
  64154. MSGesture: MSGesture;
  64155. CANNON: any;
  64156. AudioContext: AudioContext;
  64157. webkitAudioContext: AudioContext;
  64158. PointerEvent: any;
  64159. Math: Math;
  64160. Uint8Array: Uint8ArrayConstructor;
  64161. Float32Array: Float32ArrayConstructor;
  64162. mozURL: typeof URL;
  64163. msURL: typeof URL;
  64164. VRFrameData: any; // WebVR, from specs 1.1
  64165. DracoDecoderModule: any;
  64166. setImmediate(handler: (...args: any[]) => void): number;
  64167. }
  64168. interface HTMLCanvasElement {
  64169. requestPointerLock(): void;
  64170. msRequestPointerLock?(): void;
  64171. mozRequestPointerLock?(): void;
  64172. webkitRequestPointerLock?(): void;
  64173. /** Track wether a record is in progress */
  64174. isRecording: boolean;
  64175. /** Capture Stream method defined by some browsers */
  64176. captureStream(fps?: number): MediaStream;
  64177. }
  64178. interface CanvasRenderingContext2D {
  64179. msImageSmoothingEnabled: boolean;
  64180. }
  64181. interface MouseEvent {
  64182. mozMovementX: number;
  64183. mozMovementY: number;
  64184. webkitMovementX: number;
  64185. webkitMovementY: number;
  64186. msMovementX: number;
  64187. msMovementY: number;
  64188. }
  64189. interface Navigator {
  64190. mozGetVRDevices: (any: any) => any;
  64191. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64192. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64193. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64194. webkitGetGamepads(): Gamepad[];
  64195. msGetGamepads(): Gamepad[];
  64196. webkitGamepads(): Gamepad[];
  64197. }
  64198. interface HTMLVideoElement {
  64199. mozSrcObject: any;
  64200. }
  64201. interface Math {
  64202. fround(x: number): number;
  64203. imul(a: number, b: number): number;
  64204. }
  64205. interface WebGLRenderingContext {
  64206. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64207. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64208. vertexAttribDivisor(index: number, divisor: number): void;
  64209. createVertexArray(): any;
  64210. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64211. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64212. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64213. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64214. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64215. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64216. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64217. // Queries
  64218. createQuery(): WebGLQuery;
  64219. deleteQuery(query: WebGLQuery): void;
  64220. beginQuery(target: number, query: WebGLQuery): void;
  64221. endQuery(target: number): void;
  64222. getQueryParameter(query: WebGLQuery, pname: number): any;
  64223. getQuery(target: number, pname: number): any;
  64224. MAX_SAMPLES: number;
  64225. RGBA8: number;
  64226. READ_FRAMEBUFFER: number;
  64227. DRAW_FRAMEBUFFER: number;
  64228. UNIFORM_BUFFER: number;
  64229. HALF_FLOAT_OES: number;
  64230. RGBA16F: number;
  64231. RGBA32F: number;
  64232. R32F: number;
  64233. RG32F: number;
  64234. RGB32F: number;
  64235. R16F: number;
  64236. RG16F: number;
  64237. RGB16F: number;
  64238. RED: number;
  64239. RG: number;
  64240. R8: number;
  64241. RG8: number;
  64242. UNSIGNED_INT_24_8: number;
  64243. DEPTH24_STENCIL8: number;
  64244. MIN: number;
  64245. MAX: number;
  64246. /* Multiple Render Targets */
  64247. drawBuffers(buffers: number[]): void;
  64248. readBuffer(src: number): void;
  64249. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64250. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64251. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64252. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64253. // Occlusion Query
  64254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64255. ANY_SAMPLES_PASSED: number;
  64256. QUERY_RESULT_AVAILABLE: number;
  64257. QUERY_RESULT: number;
  64258. }
  64259. interface WebGLProgram {
  64260. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64261. }
  64262. interface EXT_disjoint_timer_query {
  64263. QUERY_COUNTER_BITS_EXT: number;
  64264. TIME_ELAPSED_EXT: number;
  64265. TIMESTAMP_EXT: number;
  64266. GPU_DISJOINT_EXT: number;
  64267. QUERY_RESULT_EXT: number;
  64268. QUERY_RESULT_AVAILABLE_EXT: number;
  64269. queryCounterEXT(query: WebGLQuery, target: number): void;
  64270. createQueryEXT(): WebGLQuery;
  64271. beginQueryEXT(target: number, query: WebGLQuery): void;
  64272. endQueryEXT(target: number): void;
  64273. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64274. deleteQueryEXT(query: WebGLQuery): void;
  64275. }
  64276. interface WebGLUniformLocation {
  64277. _currentState: any;
  64278. }
  64279. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64280. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64281. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64282. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64283. interface WebGLRenderingContext {
  64284. readonly RASTERIZER_DISCARD: number;
  64285. readonly DEPTH_COMPONENT24: number;
  64286. readonly TEXTURE_3D: number;
  64287. readonly TEXTURE_2D_ARRAY: number;
  64288. readonly TEXTURE_COMPARE_FUNC: number;
  64289. readonly TEXTURE_COMPARE_MODE: number;
  64290. readonly COMPARE_REF_TO_TEXTURE: number;
  64291. readonly TEXTURE_WRAP_R: number;
  64292. readonly HALF_FLOAT: number;
  64293. readonly RGB8: number;
  64294. readonly RED_INTEGER: number;
  64295. readonly RG_INTEGER: number;
  64296. readonly RGB_INTEGER: number;
  64297. readonly RGBA_INTEGER: number;
  64298. readonly R8_SNORM: number;
  64299. readonly RG8_SNORM: number;
  64300. readonly RGB8_SNORM: number;
  64301. readonly RGBA8_SNORM: number;
  64302. readonly R8I: number;
  64303. readonly RG8I: number;
  64304. readonly RGB8I: number;
  64305. readonly RGBA8I: number;
  64306. readonly R8UI: number;
  64307. readonly RG8UI: number;
  64308. readonly RGB8UI: number;
  64309. readonly RGBA8UI: number;
  64310. readonly R16I: number;
  64311. readonly RG16I: number;
  64312. readonly RGB16I: number;
  64313. readonly RGBA16I: number;
  64314. readonly R16UI: number;
  64315. readonly RG16UI: number;
  64316. readonly RGB16UI: number;
  64317. readonly RGBA16UI: number;
  64318. readonly R32I: number;
  64319. readonly RG32I: number;
  64320. readonly RGB32I: number;
  64321. readonly RGBA32I: number;
  64322. readonly R32UI: number;
  64323. readonly RG32UI: number;
  64324. readonly RGB32UI: number;
  64325. readonly RGBA32UI: number;
  64326. readonly RGB10_A2UI: number;
  64327. readonly R11F_G11F_B10F: number;
  64328. readonly RGB9_E5: number;
  64329. readonly RGB10_A2: number;
  64330. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64331. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64332. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64333. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64334. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64335. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64336. 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;
  64337. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64338. readonly TRANSFORM_FEEDBACK: number;
  64339. readonly INTERLEAVED_ATTRIBS: number;
  64340. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64341. createTransformFeedback(): WebGLTransformFeedback;
  64342. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64343. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64344. beginTransformFeedback(primitiveMode: number): void;
  64345. endTransformFeedback(): void;
  64346. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64347. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64348. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64349. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64350. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64351. }
  64352. interface ImageBitmap {
  64353. readonly width: number;
  64354. readonly height: number;
  64355. close(): void;
  64356. }
  64357. interface WebGLQuery extends WebGLObject {
  64358. }
  64359. declare var WebGLQuery: {
  64360. prototype: WebGLQuery;
  64361. new(): WebGLQuery;
  64362. };
  64363. interface WebGLSampler extends WebGLObject {
  64364. }
  64365. declare var WebGLSampler: {
  64366. prototype: WebGLSampler;
  64367. new(): WebGLSampler;
  64368. };
  64369. interface WebGLSync extends WebGLObject {
  64370. }
  64371. declare var WebGLSync: {
  64372. prototype: WebGLSync;
  64373. new(): WebGLSync;
  64374. };
  64375. interface WebGLTransformFeedback extends WebGLObject {
  64376. }
  64377. declare var WebGLTransformFeedback: {
  64378. prototype: WebGLTransformFeedback;
  64379. new(): WebGLTransformFeedback;
  64380. };
  64381. interface WebGLVertexArrayObject extends WebGLObject {
  64382. }
  64383. declare var WebGLVertexArrayObject: {
  64384. prototype: WebGLVertexArrayObject;
  64385. new(): WebGLVertexArrayObject;
  64386. };
  64387. // Type definitions for WebVR API
  64388. // Project: https://w3c.github.io/webvr/
  64389. // Definitions by: six a <https://github.com/lostfictions>
  64390. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64391. interface VRDisplay extends EventTarget {
  64392. /**
  64393. * Dictionary of capabilities describing the VRDisplay.
  64394. */
  64395. readonly capabilities: VRDisplayCapabilities;
  64396. /**
  64397. * z-depth defining the far plane of the eye view frustum
  64398. * enables mapping of values in the render target depth
  64399. * attachment to scene coordinates. Initially set to 10000.0.
  64400. */
  64401. depthFar: number;
  64402. /**
  64403. * z-depth defining the near plane of the eye view frustum
  64404. * enables mapping of values in the render target depth
  64405. * attachment to scene coordinates. Initially set to 0.01.
  64406. */
  64407. depthNear: number;
  64408. /**
  64409. * An identifier for this distinct VRDisplay. Used as an
  64410. * association point in the Gamepad API.
  64411. */
  64412. readonly displayId: number;
  64413. /**
  64414. * A display name, a user-readable name identifying it.
  64415. */
  64416. readonly displayName: string;
  64417. readonly isConnected: boolean;
  64418. readonly isPresenting: boolean;
  64419. /**
  64420. * If this VRDisplay supports room-scale experiences, the optional
  64421. * stage attribute contains details on the room-scale parameters.
  64422. */
  64423. readonly stageParameters: VRStageParameters | null;
  64424. /**
  64425. * Passing the value returned by `requestAnimationFrame` to
  64426. * `cancelAnimationFrame` will unregister the callback.
  64427. * @param handle Define the hanle of the request to cancel
  64428. */
  64429. cancelAnimationFrame(handle: number): void;
  64430. /**
  64431. * Stops presenting to the VRDisplay.
  64432. * @returns a promise to know when it stopped
  64433. */
  64434. exitPresent(): Promise<void>;
  64435. /**
  64436. * Return the current VREyeParameters for the given eye.
  64437. * @param whichEye Define the eye we want the parameter for
  64438. * @returns the eye parameters
  64439. */
  64440. getEyeParameters(whichEye: string): VREyeParameters;
  64441. /**
  64442. * Populates the passed VRFrameData with the information required to render
  64443. * the current frame.
  64444. * @param frameData Define the data structure to populate
  64445. * @returns true if ok otherwise false
  64446. */
  64447. getFrameData(frameData: VRFrameData): boolean;
  64448. /**
  64449. * Get the layers currently being presented.
  64450. * @returns the list of VR layers
  64451. */
  64452. getLayers(): VRLayer[];
  64453. /**
  64454. * Return a VRPose containing the future predicted pose of the VRDisplay
  64455. * when the current frame will be presented. The value returned will not
  64456. * change until JavaScript has returned control to the browser.
  64457. *
  64458. * The VRPose will contain the position, orientation, velocity,
  64459. * and acceleration of each of these properties.
  64460. * @returns the pose object
  64461. */
  64462. getPose(): VRPose;
  64463. /**
  64464. * Return the current instantaneous pose of the VRDisplay, with no
  64465. * prediction applied.
  64466. * @returns the current instantaneous pose
  64467. */
  64468. getImmediatePose(): VRPose;
  64469. /**
  64470. * The callback passed to `requestAnimationFrame` will be called
  64471. * any time a new frame should be rendered. When the VRDisplay is
  64472. * presenting the callback will be called at the native refresh
  64473. * rate of the HMD. When not presenting this function acts
  64474. * identically to how window.requestAnimationFrame acts. Content should
  64475. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64476. * asynchronously from other displays and at differing refresh rates.
  64477. * @param callback Define the eaction to run next frame
  64478. * @returns the request handle it
  64479. */
  64480. requestAnimationFrame(callback: FrameRequestCallback): number;
  64481. /**
  64482. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64483. * Repeat calls while already presenting will update the VRLayers being displayed.
  64484. * @param layers Define the list of layer to present
  64485. * @returns a promise to know when the request has been fulfilled
  64486. */
  64487. requestPresent(layers: VRLayer[]): Promise<void>;
  64488. /**
  64489. * Reset the pose for this display, treating its current position and
  64490. * orientation as the "origin/zero" values. VRPose.position,
  64491. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64492. * updated when calling resetPose(). This should be called in only
  64493. * sitting-space experiences.
  64494. */
  64495. resetPose(): void;
  64496. /**
  64497. * The VRLayer provided to the VRDisplay will be captured and presented
  64498. * in the HMD. Calling this function has the same effect on the source
  64499. * canvas as any other operation that uses its source image, and canvases
  64500. * created without preserveDrawingBuffer set to true will be cleared.
  64501. * @param pose Define the pose to submit
  64502. */
  64503. submitFrame(pose?: VRPose): void;
  64504. }
  64505. declare var VRDisplay: {
  64506. prototype: VRDisplay;
  64507. new(): VRDisplay;
  64508. };
  64509. interface VRLayer {
  64510. leftBounds?: number[] | Float32Array | null;
  64511. rightBounds?: number[] | Float32Array | null;
  64512. source?: HTMLCanvasElement | null;
  64513. }
  64514. interface VRDisplayCapabilities {
  64515. readonly canPresent: boolean;
  64516. readonly hasExternalDisplay: boolean;
  64517. readonly hasOrientation: boolean;
  64518. readonly hasPosition: boolean;
  64519. readonly maxLayers: number;
  64520. }
  64521. interface VREyeParameters {
  64522. /** @deprecated */
  64523. readonly fieldOfView: VRFieldOfView;
  64524. readonly offset: Float32Array;
  64525. readonly renderHeight: number;
  64526. readonly renderWidth: number;
  64527. }
  64528. interface VRFieldOfView {
  64529. readonly downDegrees: number;
  64530. readonly leftDegrees: number;
  64531. readonly rightDegrees: number;
  64532. readonly upDegrees: number;
  64533. }
  64534. interface VRFrameData {
  64535. readonly leftProjectionMatrix: Float32Array;
  64536. readonly leftViewMatrix: Float32Array;
  64537. readonly pose: VRPose;
  64538. readonly rightProjectionMatrix: Float32Array;
  64539. readonly rightViewMatrix: Float32Array;
  64540. readonly timestamp: number;
  64541. }
  64542. interface VRPose {
  64543. readonly angularAcceleration: Float32Array | null;
  64544. readonly angularVelocity: Float32Array | null;
  64545. readonly linearAcceleration: Float32Array | null;
  64546. readonly linearVelocity: Float32Array | null;
  64547. readonly orientation: Float32Array | null;
  64548. readonly position: Float32Array | null;
  64549. readonly timestamp: number;
  64550. }
  64551. interface VRStageParameters {
  64552. sittingToStandingTransform?: Float32Array;
  64553. sizeX?: number;
  64554. sizeY?: number;
  64555. }
  64556. interface Navigator {
  64557. getVRDisplays(): Promise<VRDisplay[]>;
  64558. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64559. }
  64560. interface Window {
  64561. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64562. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64563. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64564. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64565. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64566. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64567. }
  64568. interface Gamepad {
  64569. readonly displayId: number;
  64570. }
  64571. type XRSessionMode =
  64572. | "inline"
  64573. | "immersive-vr"
  64574. | "immersive-ar";
  64575. type XRReferenceSpaceType =
  64576. | "viewer"
  64577. | "local"
  64578. | "local-floor"
  64579. | "bounded-floor"
  64580. | "unbounded";
  64581. type XREnvironmentBlendMode =
  64582. | "opaque"
  64583. | "additive"
  64584. | "alpha-blend";
  64585. type XRVisibilityState =
  64586. | "visible"
  64587. | "visible-blurred"
  64588. | "hidden";
  64589. type XRHandedness =
  64590. | "none"
  64591. | "left"
  64592. | "right";
  64593. type XRTargetRayMode =
  64594. | "gaze"
  64595. | "tracked-pointer"
  64596. | "screen";
  64597. type XREye =
  64598. | "none"
  64599. | "left"
  64600. | "right";
  64601. interface XRSpace extends EventTarget {
  64602. }
  64603. interface XRRenderState {
  64604. depthNear?: number;
  64605. depthFar?: number;
  64606. inlineVerticalFieldOfView?: number;
  64607. baseLayer?: XRWebGLLayer;
  64608. }
  64609. interface XRInputSource {
  64610. handedness: XRHandedness;
  64611. targetRayMode: XRTargetRayMode;
  64612. targetRaySpace: XRSpace;
  64613. gripSpace: XRSpace | undefined;
  64614. gamepad: Gamepad | undefined;
  64615. profiles: Array<string>;
  64616. }
  64617. interface XRSession {
  64618. addEventListener: Function;
  64619. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64620. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64621. requestAnimationFrame: Function;
  64622. end(): Promise<void>;
  64623. renderState: XRRenderState;
  64624. inputSources: Array<XRInputSource>;
  64625. }
  64626. interface XRReferenceSpace extends XRSpace {
  64627. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64628. onreset: any;
  64629. }
  64630. interface XRFrame {
  64631. session: XRSession;
  64632. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64633. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64634. }
  64635. interface XRViewerPose extends XRPose {
  64636. views: Array<XRView>;
  64637. }
  64638. interface XRPose {
  64639. transform: XRRigidTransform;
  64640. emulatedPosition: boolean;
  64641. }
  64642. declare var XRWebGLLayer: {
  64643. prototype: XRWebGLLayer;
  64644. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64645. };
  64646. interface XRWebGLLayer {
  64647. framebuffer: WebGLFramebuffer;
  64648. framebufferWidth: number;
  64649. framebufferHeight: number;
  64650. getViewport: Function;
  64651. }
  64652. interface XRRigidTransform {
  64653. position: DOMPointReadOnly;
  64654. orientation: DOMPointReadOnly;
  64655. matrix: Float32Array;
  64656. inverse: XRRigidTransform;
  64657. }
  64658. interface XRView {
  64659. eye: XREye;
  64660. projectionMatrix: Float32Array;
  64661. transform: XRRigidTransform;
  64662. }
  64663. interface XRInputSourceChangeEvent {
  64664. session: XRSession;
  64665. removed: Array<XRInputSource>;
  64666. added: Array<XRInputSource>;
  64667. }
  64668. /**
  64669. * @ignore
  64670. */
  64671. declare module BABYLON.GLTF2.Exporter {
  64672. }
  64673. /**
  64674. * @ignore
  64675. */
  64676. declare module BABYLON.GLTF1 {
  64677. }
  64678. declare module BABYLON.GUI {
  64679. /**
  64680. * Class used to specific a value and its associated unit
  64681. */
  64682. export class ValueAndUnit {
  64683. /** defines the unit to store */
  64684. unit: number;
  64685. /** defines a boolean indicating if the value can be negative */
  64686. negativeValueAllowed: boolean;
  64687. private _value;
  64688. private _originalUnit;
  64689. /**
  64690. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64691. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64692. */
  64693. ignoreAdaptiveScaling: boolean;
  64694. /**
  64695. * Creates a new ValueAndUnit
  64696. * @param value defines the value to store
  64697. * @param unit defines the unit to store
  64698. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64699. */
  64700. constructor(value: number,
  64701. /** defines the unit to store */
  64702. unit?: number,
  64703. /** defines a boolean indicating if the value can be negative */
  64704. negativeValueAllowed?: boolean);
  64705. /** Gets a boolean indicating if the value is a percentage */
  64706. readonly isPercentage: boolean;
  64707. /** Gets a boolean indicating if the value is store as pixel */
  64708. readonly isPixel: boolean;
  64709. /** Gets direct internal value */
  64710. readonly internalValue: number;
  64711. /**
  64712. * Gets value as pixel
  64713. * @param host defines the root host
  64714. * @param refValue defines the reference value for percentages
  64715. * @returns the value as pixel
  64716. */
  64717. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64718. /**
  64719. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64720. * @param value defines the value to store
  64721. * @param unit defines the unit to store
  64722. * @returns the current ValueAndUnit
  64723. */
  64724. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64725. /**
  64726. * Gets the value accordingly to its unit
  64727. * @param host defines the root host
  64728. * @returns the value
  64729. */
  64730. getValue(host: AdvancedDynamicTexture): number;
  64731. /**
  64732. * Gets a string representation of the value
  64733. * @param host defines the root host
  64734. * @param decimals defines an optional number of decimals to display
  64735. * @returns a string
  64736. */
  64737. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64738. /**
  64739. * Store a value parsed from a string
  64740. * @param source defines the source string
  64741. * @returns true if the value was successfully parsed
  64742. */
  64743. fromString(source: string | number): boolean;
  64744. private static _Regex;
  64745. private static _UNITMODE_PERCENTAGE;
  64746. private static _UNITMODE_PIXEL;
  64747. /** UNITMODE_PERCENTAGE */
  64748. static readonly UNITMODE_PERCENTAGE: number;
  64749. /** UNITMODE_PIXEL */
  64750. static readonly UNITMODE_PIXEL: number;
  64751. }
  64752. }
  64753. declare module BABYLON.GUI {
  64754. /**
  64755. * Define a style used by control to automatically setup properties based on a template.
  64756. * Only support font related properties so far
  64757. */
  64758. export class Style implements BABYLON.IDisposable {
  64759. private _fontFamily;
  64760. private _fontStyle;
  64761. private _fontWeight;
  64762. /** @hidden */
  64763. _host: AdvancedDynamicTexture;
  64764. /** @hidden */
  64765. _fontSize: ValueAndUnit;
  64766. /**
  64767. * BABYLON.Observable raised when the style values are changed
  64768. */
  64769. onChangedObservable: BABYLON.Observable<Style>;
  64770. /**
  64771. * Creates a new style object
  64772. * @param host defines the AdvancedDynamicTexture which hosts this style
  64773. */
  64774. constructor(host: AdvancedDynamicTexture);
  64775. /**
  64776. * Gets or sets the font size
  64777. */
  64778. fontSize: string | number;
  64779. /**
  64780. * Gets or sets the font family
  64781. */
  64782. fontFamily: string;
  64783. /**
  64784. * Gets or sets the font style
  64785. */
  64786. fontStyle: string;
  64787. /** Gets or sets font weight */
  64788. fontWeight: string;
  64789. /** Dispose all associated resources */
  64790. dispose(): void;
  64791. }
  64792. }
  64793. declare module BABYLON.GUI {
  64794. /**
  64795. * Class used to transport BABYLON.Vector2 information for pointer events
  64796. */
  64797. export class Vector2WithInfo extends BABYLON.Vector2 {
  64798. /** defines the current mouse button index */
  64799. buttonIndex: number;
  64800. /**
  64801. * Creates a new Vector2WithInfo
  64802. * @param source defines the vector2 data to transport
  64803. * @param buttonIndex defines the current mouse button index
  64804. */
  64805. constructor(source: BABYLON.Vector2,
  64806. /** defines the current mouse button index */
  64807. buttonIndex?: number);
  64808. }
  64809. /** Class used to provide 2D matrix features */
  64810. export class Matrix2D {
  64811. /** Gets the internal array of 6 floats used to store matrix data */
  64812. m: Float32Array;
  64813. /**
  64814. * Creates a new matrix
  64815. * @param m00 defines value for (0, 0)
  64816. * @param m01 defines value for (0, 1)
  64817. * @param m10 defines value for (1, 0)
  64818. * @param m11 defines value for (1, 1)
  64819. * @param m20 defines value for (2, 0)
  64820. * @param m21 defines value for (2, 1)
  64821. */
  64822. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64823. /**
  64824. * Fills the matrix from direct values
  64825. * @param m00 defines value for (0, 0)
  64826. * @param m01 defines value for (0, 1)
  64827. * @param m10 defines value for (1, 0)
  64828. * @param m11 defines value for (1, 1)
  64829. * @param m20 defines value for (2, 0)
  64830. * @param m21 defines value for (2, 1)
  64831. * @returns the current modified matrix
  64832. */
  64833. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64834. /**
  64835. * Gets matrix determinant
  64836. * @returns the determinant
  64837. */
  64838. determinant(): number;
  64839. /**
  64840. * Inverses the matrix and stores it in a target matrix
  64841. * @param result defines the target matrix
  64842. * @returns the current matrix
  64843. */
  64844. invertToRef(result: Matrix2D): Matrix2D;
  64845. /**
  64846. * Multiplies the current matrix with another one
  64847. * @param other defines the second operand
  64848. * @param result defines the target matrix
  64849. * @returns the current matrix
  64850. */
  64851. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64852. /**
  64853. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64854. * @param x defines the x coordinate to transform
  64855. * @param y defines the x coordinate to transform
  64856. * @param result defines the target vector2
  64857. * @returns the current matrix
  64858. */
  64859. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64860. /**
  64861. * Creates an identity matrix
  64862. * @returns a new matrix
  64863. */
  64864. static Identity(): Matrix2D;
  64865. /**
  64866. * Creates a translation matrix and stores it in a target matrix
  64867. * @param x defines the x coordinate of the translation
  64868. * @param y defines the y coordinate of the translation
  64869. * @param result defines the target matrix
  64870. */
  64871. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64872. /**
  64873. * Creates a scaling matrix and stores it in a target matrix
  64874. * @param x defines the x coordinate of the scaling
  64875. * @param y defines the y coordinate of the scaling
  64876. * @param result defines the target matrix
  64877. */
  64878. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64879. /**
  64880. * Creates a rotation matrix and stores it in a target matrix
  64881. * @param angle defines the rotation angle
  64882. * @param result defines the target matrix
  64883. */
  64884. static RotationToRef(angle: number, result: Matrix2D): void;
  64885. private static _TempPreTranslationMatrix;
  64886. private static _TempPostTranslationMatrix;
  64887. private static _TempRotationMatrix;
  64888. private static _TempScalingMatrix;
  64889. private static _TempCompose0;
  64890. private static _TempCompose1;
  64891. private static _TempCompose2;
  64892. /**
  64893. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64894. * @param tx defines the x coordinate of the translation
  64895. * @param ty defines the y coordinate of the translation
  64896. * @param angle defines the rotation angle
  64897. * @param scaleX defines the x coordinate of the scaling
  64898. * @param scaleY defines the y coordinate of the scaling
  64899. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64900. * @param result defines the target matrix
  64901. */
  64902. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64903. }
  64904. }
  64905. declare module BABYLON.GUI {
  64906. /**
  64907. * Class used to store 2D control sizes
  64908. */
  64909. export class Measure {
  64910. /** defines left coordinate */
  64911. left: number;
  64912. /** defines top coordinate */
  64913. top: number;
  64914. /** defines width dimension */
  64915. width: number;
  64916. /** defines height dimension */
  64917. height: number;
  64918. /**
  64919. * Creates a new measure
  64920. * @param left defines left coordinate
  64921. * @param top defines top coordinate
  64922. * @param width defines width dimension
  64923. * @param height defines height dimension
  64924. */
  64925. constructor(
  64926. /** defines left coordinate */
  64927. left: number,
  64928. /** defines top coordinate */
  64929. top: number,
  64930. /** defines width dimension */
  64931. width: number,
  64932. /** defines height dimension */
  64933. height: number);
  64934. /**
  64935. * Copy from another measure
  64936. * @param other defines the other measure to copy from
  64937. */
  64938. copyFrom(other: Measure): void;
  64939. /**
  64940. * Copy from a group of 4 floats
  64941. * @param left defines left coordinate
  64942. * @param top defines top coordinate
  64943. * @param width defines width dimension
  64944. * @param height defines height dimension
  64945. */
  64946. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64947. /**
  64948. * Computes the axis aligned bounding box measure for two given measures
  64949. * @param a Input measure
  64950. * @param b Input measure
  64951. * @param result the resulting bounding measure
  64952. */
  64953. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64954. /**
  64955. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64956. * @param transform the matrix to transform the measure before computing the AABB
  64957. * @param result the resulting AABB
  64958. */
  64959. transformToRef(transform: Matrix2D, result: Measure): void;
  64960. /**
  64961. * Check equality between this measure and another one
  64962. * @param other defines the other measures
  64963. * @returns true if both measures are equals
  64964. */
  64965. isEqualsTo(other: Measure): boolean;
  64966. /**
  64967. * Creates an empty measure
  64968. * @returns a new measure
  64969. */
  64970. static Empty(): Measure;
  64971. }
  64972. }
  64973. declare module BABYLON.GUI {
  64974. /**
  64975. * Interface used to define a control that can receive focus
  64976. */
  64977. export interface IFocusableControl {
  64978. /**
  64979. * Function called when the control receives the focus
  64980. */
  64981. onFocus(): void;
  64982. /**
  64983. * Function called when the control loses the focus
  64984. */
  64985. onBlur(): void;
  64986. /**
  64987. * Function called to let the control handle keyboard events
  64988. * @param evt defines the current keyboard event
  64989. */
  64990. processKeyboard(evt: KeyboardEvent): void;
  64991. /**
  64992. * Function called to get the list of controls that should not steal the focus from this control
  64993. * @returns an array of controls
  64994. */
  64995. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64996. }
  64997. /**
  64998. * Class used to create texture to support 2D GUI elements
  64999. * @see http://doc.babylonjs.com/how_to/gui
  65000. */
  65001. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  65002. private _isDirty;
  65003. private _renderObserver;
  65004. private _resizeObserver;
  65005. private _preKeyboardObserver;
  65006. private _pointerMoveObserver;
  65007. private _pointerObserver;
  65008. private _canvasPointerOutObserver;
  65009. private _background;
  65010. /** @hidden */
  65011. _rootContainer: Container;
  65012. /** @hidden */
  65013. _lastPickedControl: Control;
  65014. /** @hidden */
  65015. _lastControlOver: {
  65016. [pointerId: number]: Control;
  65017. };
  65018. /** @hidden */
  65019. _lastControlDown: {
  65020. [pointerId: number]: Control;
  65021. };
  65022. /** @hidden */
  65023. _capturingControl: {
  65024. [pointerId: number]: Control;
  65025. };
  65026. /** @hidden */
  65027. _shouldBlockPointer: boolean;
  65028. /** @hidden */
  65029. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  65030. /** @hidden */
  65031. _linkedControls: Control[];
  65032. private _isFullscreen;
  65033. private _fullscreenViewport;
  65034. private _idealWidth;
  65035. private _idealHeight;
  65036. private _useSmallestIdeal;
  65037. private _renderAtIdealSize;
  65038. private _focusedControl;
  65039. private _blockNextFocusCheck;
  65040. private _renderScale;
  65041. private _rootCanvas;
  65042. private _cursorChanged;
  65043. /**
  65044. * Define type to string to ensure compatibility across browsers
  65045. * Safari doesn't support DataTransfer constructor
  65046. */
  65047. private _clipboardData;
  65048. /**
  65049. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  65050. */
  65051. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  65052. /**
  65053. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  65054. */
  65055. onControlPickedObservable: BABYLON.Observable<Control>;
  65056. /**
  65057. * BABYLON.Observable event triggered before layout is evaluated
  65058. */
  65059. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65060. /**
  65061. * BABYLON.Observable event triggered after the layout was evaluated
  65062. */
  65063. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65064. /**
  65065. * BABYLON.Observable event triggered before the texture is rendered
  65066. */
  65067. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65068. /**
  65069. * BABYLON.Observable event triggered after the texture was rendered
  65070. */
  65071. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65072. /**
  65073. * Gets or sets a boolean defining if alpha is stored as premultiplied
  65074. */
  65075. premulAlpha: boolean;
  65076. /**
  65077. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  65078. * Useful when you want more antialiasing
  65079. */
  65080. renderScale: number;
  65081. /** Gets or sets the background color */
  65082. background: string;
  65083. /**
  65084. * Gets or sets the ideal width used to design controls.
  65085. * The GUI will then rescale everything accordingly
  65086. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65087. */
  65088. idealWidth: number;
  65089. /**
  65090. * Gets or sets the ideal height used to design controls.
  65091. * The GUI will then rescale everything accordingly
  65092. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65093. */
  65094. idealHeight: number;
  65095. /**
  65096. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  65097. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65098. */
  65099. useSmallestIdeal: boolean;
  65100. /**
  65101. * Gets or sets a boolean indicating if adaptive scaling must be used
  65102. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65103. */
  65104. renderAtIdealSize: boolean;
  65105. /**
  65106. * Gets the underlying layer used to render the texture when in fullscreen mode
  65107. */
  65108. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  65109. /**
  65110. * Gets the root container control
  65111. */
  65112. readonly rootContainer: Container;
  65113. /**
  65114. * Returns an array containing the root container.
  65115. * This is mostly used to let the Inspector introspects the ADT
  65116. * @returns an array containing the rootContainer
  65117. */
  65118. getChildren(): Array<Container>;
  65119. /**
  65120. * Will return all controls that are inside this texture
  65121. * @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
  65122. * @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
  65123. * @return all child controls
  65124. */
  65125. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65126. /**
  65127. * Gets or sets the current focused control
  65128. */
  65129. focusedControl: BABYLON.Nullable<IFocusableControl>;
  65130. /**
  65131. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  65132. */
  65133. isForeground: boolean;
  65134. /**
  65135. * Gets or set information about clipboardData
  65136. */
  65137. clipboardData: string;
  65138. /**
  65139. * Creates a new AdvancedDynamicTexture
  65140. * @param name defines the name of the texture
  65141. * @param width defines the width of the texture
  65142. * @param height defines the height of the texture
  65143. * @param scene defines the hosting scene
  65144. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  65145. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  65146. */
  65147. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  65148. /**
  65149. * Get the current class name of the texture useful for serialization or dynamic coding.
  65150. * @returns "AdvancedDynamicTexture"
  65151. */
  65152. getClassName(): string;
  65153. /**
  65154. * Function used to execute a function on all controls
  65155. * @param func defines the function to execute
  65156. * @param container defines the container where controls belong. If null the root container will be used
  65157. */
  65158. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  65159. private _useInvalidateRectOptimization;
  65160. /**
  65161. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  65162. */
  65163. useInvalidateRectOptimization: boolean;
  65164. private _invalidatedRectangle;
  65165. /**
  65166. * Invalidates a rectangle area on the gui texture
  65167. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  65168. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  65169. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  65170. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  65171. */
  65172. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  65173. /**
  65174. * Marks the texture as dirty forcing a complete update
  65175. */
  65176. markAsDirty(): void;
  65177. /**
  65178. * Helper function used to create a new style
  65179. * @returns a new style
  65180. * @see http://doc.babylonjs.com/how_to/gui#styles
  65181. */
  65182. createStyle(): Style;
  65183. /**
  65184. * Adds a new control to the root container
  65185. * @param control defines the control to add
  65186. * @returns the current texture
  65187. */
  65188. addControl(control: Control): AdvancedDynamicTexture;
  65189. /**
  65190. * Removes a control from the root container
  65191. * @param control defines the control to remove
  65192. * @returns the current texture
  65193. */
  65194. removeControl(control: Control): AdvancedDynamicTexture;
  65195. /**
  65196. * Release all resources
  65197. */
  65198. dispose(): void;
  65199. private _onResize;
  65200. /** @hidden */
  65201. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  65202. /**
  65203. * Get screen coordinates for a vector3
  65204. * @param position defines the position to project
  65205. * @param worldMatrix defines the world matrix to use
  65206. * @returns the projected position
  65207. */
  65208. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  65209. private _checkUpdate;
  65210. private _clearMeasure;
  65211. private _render;
  65212. /** @hidden */
  65213. _changeCursor(cursor: string): void;
  65214. /** @hidden */
  65215. _registerLastControlDown(control: Control, pointerId: number): void;
  65216. private _doPicking;
  65217. /** @hidden */
  65218. _cleanControlAfterRemovalFromList(list: {
  65219. [pointerId: number]: Control;
  65220. }, control: Control): void;
  65221. /** @hidden */
  65222. _cleanControlAfterRemoval(control: Control): void;
  65223. /** Attach to all scene events required to support pointer events */
  65224. attach(): void;
  65225. /** @hidden */
  65226. private onClipboardCopy;
  65227. /** @hidden */
  65228. private onClipboardCut;
  65229. /** @hidden */
  65230. private onClipboardPaste;
  65231. /**
  65232. * Register the clipboard Events onto the canvas
  65233. */
  65234. registerClipboardEvents(): void;
  65235. /**
  65236. * Unregister the clipboard Events from the canvas
  65237. */
  65238. unRegisterClipboardEvents(): void;
  65239. /**
  65240. * Connect the texture to a hosting mesh to enable interactions
  65241. * @param mesh defines the mesh to attach to
  65242. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  65243. */
  65244. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  65245. /**
  65246. * Move the focus to a specific control
  65247. * @param control defines the control which will receive the focus
  65248. */
  65249. moveFocusToControl(control: IFocusableControl): void;
  65250. private _manageFocus;
  65251. private _attachToOnPointerOut;
  65252. /**
  65253. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  65254. * @param mesh defines the mesh which will receive the texture
  65255. * @param width defines the texture width (1024 by default)
  65256. * @param height defines the texture height (1024 by default)
  65257. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  65258. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  65259. * @returns a new AdvancedDynamicTexture
  65260. */
  65261. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  65262. /**
  65263. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  65264. * In this mode the texture will rely on a layer for its rendering.
  65265. * This allows it to be treated like any other layer.
  65266. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  65267. * LayerMask is set through advancedTexture.layer.layerMask
  65268. * @param name defines name for the texture
  65269. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  65270. * @param scene defines the hsoting scene
  65271. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  65272. * @returns a new AdvancedDynamicTexture
  65273. */
  65274. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  65275. }
  65276. }
  65277. declare module BABYLON.GUI {
  65278. /**
  65279. * Root class used for all 2D controls
  65280. * @see http://doc.babylonjs.com/how_to/gui#controls
  65281. */
  65282. export class Control {
  65283. /** defines the name of the control */
  65284. name?: string | undefined;
  65285. /**
  65286. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  65287. */
  65288. static AllowAlphaInheritance: boolean;
  65289. private _alpha;
  65290. private _alphaSet;
  65291. private _zIndex;
  65292. /** @hidden */
  65293. _host: AdvancedDynamicTexture;
  65294. /** Gets or sets the control parent */
  65295. parent: BABYLON.Nullable<Container>;
  65296. /** @hidden */
  65297. _currentMeasure: Measure;
  65298. private _fontFamily;
  65299. private _fontStyle;
  65300. private _fontWeight;
  65301. private _fontSize;
  65302. private _font;
  65303. /** @hidden */
  65304. _width: ValueAndUnit;
  65305. /** @hidden */
  65306. _height: ValueAndUnit;
  65307. /** @hidden */
  65308. protected _fontOffset: {
  65309. ascent: number;
  65310. height: number;
  65311. descent: number;
  65312. };
  65313. private _color;
  65314. private _style;
  65315. private _styleObserver;
  65316. /** @hidden */
  65317. protected _horizontalAlignment: number;
  65318. /** @hidden */
  65319. protected _verticalAlignment: number;
  65320. /** @hidden */
  65321. protected _isDirty: boolean;
  65322. /** @hidden */
  65323. protected _wasDirty: boolean;
  65324. /** @hidden */
  65325. _tempParentMeasure: Measure;
  65326. /** @hidden */
  65327. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65328. /** @hidden */
  65329. protected _cachedParentMeasure: Measure;
  65330. private _paddingLeft;
  65331. private _paddingRight;
  65332. private _paddingTop;
  65333. private _paddingBottom;
  65334. /** @hidden */
  65335. _left: ValueAndUnit;
  65336. /** @hidden */
  65337. _top: ValueAndUnit;
  65338. private _scaleX;
  65339. private _scaleY;
  65340. private _rotation;
  65341. private _transformCenterX;
  65342. private _transformCenterY;
  65343. /** @hidden */
  65344. _transformMatrix: Matrix2D;
  65345. /** @hidden */
  65346. protected _invertTransformMatrix: Matrix2D;
  65347. /** @hidden */
  65348. protected _transformedPosition: BABYLON.Vector2;
  65349. private _isMatrixDirty;
  65350. private _cachedOffsetX;
  65351. private _cachedOffsetY;
  65352. private _isVisible;
  65353. private _isHighlighted;
  65354. /** @hidden */
  65355. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65356. private _fontSet;
  65357. private _dummyVector2;
  65358. private _downCount;
  65359. private _enterCount;
  65360. private _doNotRender;
  65361. private _downPointerIds;
  65362. protected _isEnabled: boolean;
  65363. protected _disabledColor: string;
  65364. /** @hidden */
  65365. protected _rebuildLayout: boolean;
  65366. /** @hidden */
  65367. _isClipped: boolean;
  65368. /** @hidden */
  65369. _tag: any;
  65370. /**
  65371. * 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
  65372. */
  65373. uniqueId: number;
  65374. /**
  65375. * Gets or sets an object used to store user defined information for the node
  65376. */
  65377. metadata: any;
  65378. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65379. isHitTestVisible: boolean;
  65380. /** Gets or sets a boolean indicating if the control can block pointer events */
  65381. isPointerBlocker: boolean;
  65382. /** Gets or sets a boolean indicating if the control can be focusable */
  65383. isFocusInvisible: boolean;
  65384. /**
  65385. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65386. * 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
  65387. */
  65388. clipChildren: boolean;
  65389. /**
  65390. * Gets or sets a boolean indicating that control content must be clipped
  65391. * 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
  65392. */
  65393. clipContent: boolean;
  65394. /**
  65395. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65396. */
  65397. useBitmapCache: boolean;
  65398. private _cacheData;
  65399. private _shadowOffsetX;
  65400. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65401. shadowOffsetX: number;
  65402. private _shadowOffsetY;
  65403. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65404. shadowOffsetY: number;
  65405. private _shadowBlur;
  65406. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65407. shadowBlur: number;
  65408. private _shadowColor;
  65409. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65410. shadowColor: string;
  65411. /** Gets or sets the cursor to use when the control is hovered */
  65412. hoverCursor: string;
  65413. /** @hidden */
  65414. protected _linkOffsetX: ValueAndUnit;
  65415. /** @hidden */
  65416. protected _linkOffsetY: ValueAndUnit;
  65417. /** Gets the control type name */
  65418. readonly typeName: string;
  65419. /**
  65420. * Get the current class name of the control.
  65421. * @returns current class name
  65422. */
  65423. getClassName(): string;
  65424. /**
  65425. * An event triggered when the pointer move over the control.
  65426. */
  65427. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65428. /**
  65429. * An event triggered when the pointer move out of the control.
  65430. */
  65431. onPointerOutObservable: BABYLON.Observable<Control>;
  65432. /**
  65433. * An event triggered when the pointer taps the control
  65434. */
  65435. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65436. /**
  65437. * An event triggered when pointer up
  65438. */
  65439. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65440. /**
  65441. * An event triggered when a control is clicked on
  65442. */
  65443. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65444. /**
  65445. * An event triggered when pointer enters the control
  65446. */
  65447. onPointerEnterObservable: BABYLON.Observable<Control>;
  65448. /**
  65449. * An event triggered when the control is marked as dirty
  65450. */
  65451. onDirtyObservable: BABYLON.Observable<Control>;
  65452. /**
  65453. * An event triggered before drawing the control
  65454. */
  65455. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65456. /**
  65457. * An event triggered after the control was drawn
  65458. */
  65459. onAfterDrawObservable: BABYLON.Observable<Control>;
  65460. /**
  65461. * Get the hosting AdvancedDynamicTexture
  65462. */
  65463. readonly host: AdvancedDynamicTexture;
  65464. /** Gets or set information about font offsets (used to render and align text) */
  65465. fontOffset: {
  65466. ascent: number;
  65467. height: number;
  65468. descent: number;
  65469. };
  65470. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65471. alpha: number;
  65472. /**
  65473. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65474. */
  65475. isHighlighted: boolean;
  65476. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65477. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65478. */
  65479. scaleX: number;
  65480. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65481. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65482. */
  65483. scaleY: number;
  65484. /** Gets or sets the rotation angle (0 by default)
  65485. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65486. */
  65487. rotation: number;
  65488. /** Gets or sets the transformation center on Y axis (0 by default)
  65489. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65490. */
  65491. transformCenterY: number;
  65492. /** Gets or sets the transformation center on X axis (0 by default)
  65493. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65494. */
  65495. transformCenterX: number;
  65496. /**
  65497. * Gets or sets the horizontal alignment
  65498. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65499. */
  65500. horizontalAlignment: number;
  65501. /**
  65502. * Gets or sets the vertical alignment
  65503. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65504. */
  65505. verticalAlignment: number;
  65506. /**
  65507. * Gets or sets control width
  65508. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65509. */
  65510. width: string | number;
  65511. /**
  65512. * Gets or sets the control width in pixel
  65513. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65514. */
  65515. widthInPixels: number;
  65516. /**
  65517. * Gets or sets control height
  65518. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65519. */
  65520. height: string | number;
  65521. /**
  65522. * Gets or sets control height in pixel
  65523. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65524. */
  65525. heightInPixels: number;
  65526. /** Gets or set font family */
  65527. fontFamily: string;
  65528. /** Gets or sets font style */
  65529. fontStyle: string;
  65530. /** Gets or sets font weight */
  65531. fontWeight: string;
  65532. /**
  65533. * Gets or sets style
  65534. * @see http://doc.babylonjs.com/how_to/gui#styles
  65535. */
  65536. style: BABYLON.Nullable<Style>;
  65537. /** @hidden */
  65538. readonly _isFontSizeInPercentage: boolean;
  65539. /** Gets or sets font size in pixels */
  65540. fontSizeInPixels: number;
  65541. /** Gets or sets font size */
  65542. fontSize: string | number;
  65543. /** Gets or sets foreground color */
  65544. color: string;
  65545. /** Gets or sets z index which is used to reorder controls on the z axis */
  65546. zIndex: number;
  65547. /** Gets or sets a boolean indicating if the control can be rendered */
  65548. notRenderable: boolean;
  65549. /** Gets or sets a boolean indicating if the control is visible */
  65550. isVisible: boolean;
  65551. /** Gets a boolean indicating that the control needs to update its rendering */
  65552. readonly isDirty: boolean;
  65553. /**
  65554. * Gets the current linked mesh (or null if none)
  65555. */
  65556. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65557. /**
  65558. * Gets or sets a value indicating the padding to use on the left of the control
  65559. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65560. */
  65561. paddingLeft: string | number;
  65562. /**
  65563. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65564. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65565. */
  65566. paddingLeftInPixels: number;
  65567. /**
  65568. * Gets or sets a value indicating the padding to use on the right of the control
  65569. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65570. */
  65571. paddingRight: string | number;
  65572. /**
  65573. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65574. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65575. */
  65576. paddingRightInPixels: number;
  65577. /**
  65578. * Gets or sets a value indicating the padding to use on the top of the control
  65579. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65580. */
  65581. paddingTop: string | number;
  65582. /**
  65583. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65584. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65585. */
  65586. paddingTopInPixels: number;
  65587. /**
  65588. * Gets or sets a value indicating the padding to use on the bottom of the control
  65589. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65590. */
  65591. paddingBottom: string | number;
  65592. /**
  65593. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65594. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65595. */
  65596. paddingBottomInPixels: number;
  65597. /**
  65598. * Gets or sets a value indicating the left coordinate of the control
  65599. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65600. */
  65601. left: string | number;
  65602. /**
  65603. * Gets or sets a value indicating the left coordinate in pixels of the control
  65604. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65605. */
  65606. leftInPixels: number;
  65607. /**
  65608. * Gets or sets a value indicating the top coordinate of the control
  65609. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65610. */
  65611. top: string | number;
  65612. /**
  65613. * Gets or sets a value indicating the top coordinate in pixels of the control
  65614. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65615. */
  65616. topInPixels: number;
  65617. /**
  65618. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65619. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65620. */
  65621. linkOffsetX: string | number;
  65622. /**
  65623. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65624. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65625. */
  65626. linkOffsetXInPixels: number;
  65627. /**
  65628. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65629. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65630. */
  65631. linkOffsetY: string | number;
  65632. /**
  65633. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65634. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65635. */
  65636. linkOffsetYInPixels: number;
  65637. /** Gets the center coordinate on X axis */
  65638. readonly centerX: number;
  65639. /** Gets the center coordinate on Y axis */
  65640. readonly centerY: number;
  65641. /** Gets or sets if control is Enabled*/
  65642. isEnabled: boolean;
  65643. /** Gets or sets background color of control if it's disabled*/
  65644. disabledColor: string;
  65645. /**
  65646. * Creates a new control
  65647. * @param name defines the name of the control
  65648. */
  65649. constructor(
  65650. /** defines the name of the control */
  65651. name?: string | undefined);
  65652. /** @hidden */
  65653. protected _getTypeName(): string;
  65654. /**
  65655. * Gets the first ascendant in the hierarchy of the given type
  65656. * @param className defines the required type
  65657. * @returns the ascendant or null if not found
  65658. */
  65659. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65660. /** @hidden */
  65661. _resetFontCache(): void;
  65662. /**
  65663. * Determines if a container is an ascendant of the current control
  65664. * @param container defines the container to look for
  65665. * @returns true if the container is one of the ascendant of the control
  65666. */
  65667. isAscendant(container: Control): boolean;
  65668. /**
  65669. * Gets coordinates in local control space
  65670. * @param globalCoordinates defines the coordinates to transform
  65671. * @returns the new coordinates in local space
  65672. */
  65673. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65674. /**
  65675. * Gets coordinates in local control space
  65676. * @param globalCoordinates defines the coordinates to transform
  65677. * @param result defines the target vector2 where to store the result
  65678. * @returns the current control
  65679. */
  65680. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65681. /**
  65682. * Gets coordinates in parent local control space
  65683. * @param globalCoordinates defines the coordinates to transform
  65684. * @returns the new coordinates in parent local space
  65685. */
  65686. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65687. /**
  65688. * Move the current control to a vector3 position projected onto the screen.
  65689. * @param position defines the target position
  65690. * @param scene defines the hosting scene
  65691. */
  65692. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65693. /** @hidden */
  65694. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65695. /**
  65696. * Will return all controls that have this control as ascendant
  65697. * @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
  65698. * @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
  65699. * @return all child controls
  65700. */
  65701. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65702. /**
  65703. * Link current control with a target mesh
  65704. * @param mesh defines the mesh to link with
  65705. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65706. */
  65707. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65708. /** @hidden */
  65709. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65710. /** @hidden */
  65711. _offsetLeft(offset: number): void;
  65712. /** @hidden */
  65713. _offsetTop(offset: number): void;
  65714. /** @hidden */
  65715. _markMatrixAsDirty(): void;
  65716. /** @hidden */
  65717. _flagDescendantsAsMatrixDirty(): void;
  65718. /** @hidden */
  65719. _intersectsRect(rect: Measure): boolean;
  65720. /** @hidden */
  65721. protected invalidateRect(): void;
  65722. /** @hidden */
  65723. _markAsDirty(force?: boolean): void;
  65724. /** @hidden */
  65725. _markAllAsDirty(): void;
  65726. /** @hidden */
  65727. _link(host: AdvancedDynamicTexture): void;
  65728. /** @hidden */
  65729. protected _transform(context?: CanvasRenderingContext2D): void;
  65730. /** @hidden */
  65731. _renderHighlight(context: CanvasRenderingContext2D): void;
  65732. /** @hidden */
  65733. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65734. /** @hidden */
  65735. protected _applyStates(context: CanvasRenderingContext2D): void;
  65736. /** @hidden */
  65737. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65738. /** @hidden */
  65739. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65740. protected _evaluateClippingState(parentMeasure: Measure): void;
  65741. /** @hidden */
  65742. _measure(): void;
  65743. /** @hidden */
  65744. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65745. /** @hidden */
  65746. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65747. /** @hidden */
  65748. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65749. /** @hidden */
  65750. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65751. private static _ClipMeasure;
  65752. private _tmpMeasureA;
  65753. private _clip;
  65754. /** @hidden */
  65755. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65756. /** @hidden */
  65757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65758. /**
  65759. * Tests if a given coordinates belong to the current control
  65760. * @param x defines x coordinate to test
  65761. * @param y defines y coordinate to test
  65762. * @returns true if the coordinates are inside the control
  65763. */
  65764. contains(x: number, y: number): boolean;
  65765. /** @hidden */
  65766. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65767. /** @hidden */
  65768. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65769. /** @hidden */
  65770. _onPointerEnter(target: Control): boolean;
  65771. /** @hidden */
  65772. _onPointerOut(target: Control, force?: boolean): void;
  65773. /** @hidden */
  65774. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65775. /** @hidden */
  65776. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65777. /** @hidden */
  65778. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65779. /** @hidden */
  65780. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65781. private _prepareFont;
  65782. /** Releases associated resources */
  65783. dispose(): void;
  65784. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65785. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65786. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65787. private static _VERTICAL_ALIGNMENT_TOP;
  65788. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65789. private static _VERTICAL_ALIGNMENT_CENTER;
  65790. /** HORIZONTAL_ALIGNMENT_LEFT */
  65791. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65792. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65793. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65794. /** HORIZONTAL_ALIGNMENT_CENTER */
  65795. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65796. /** VERTICAL_ALIGNMENT_TOP */
  65797. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65798. /** VERTICAL_ALIGNMENT_BOTTOM */
  65799. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65800. /** VERTICAL_ALIGNMENT_CENTER */
  65801. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65802. private static _FontHeightSizes;
  65803. /** @hidden */
  65804. static _GetFontOffset(font: string): {
  65805. ascent: number;
  65806. height: number;
  65807. descent: number;
  65808. };
  65809. /**
  65810. * Creates a stack panel that can be used to render headers
  65811. * @param control defines the control to associate with the header
  65812. * @param text defines the text of the header
  65813. * @param size defines the size of the header
  65814. * @param options defines options used to configure the header
  65815. * @returns a new StackPanel
  65816. * @ignore
  65817. * @hidden
  65818. */
  65819. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65820. isHorizontal: boolean;
  65821. controlFirst: boolean;
  65822. }) => any;
  65823. /** @hidden */
  65824. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65825. }
  65826. }
  65827. declare module BABYLON.GUI {
  65828. /**
  65829. * Root class for 2D containers
  65830. * @see http://doc.babylonjs.com/how_to/gui#containers
  65831. */
  65832. export class Container extends Control {
  65833. name?: string | undefined;
  65834. /** @hidden */
  65835. protected _children: Control[];
  65836. /** @hidden */
  65837. protected _measureForChildren: Measure;
  65838. /** @hidden */
  65839. protected _background: string;
  65840. /** @hidden */
  65841. protected _adaptWidthToChildren: boolean;
  65842. /** @hidden */
  65843. protected _adaptHeightToChildren: boolean;
  65844. /**
  65845. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65846. */
  65847. logLayoutCycleErrors: boolean;
  65848. /**
  65849. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65850. */
  65851. maxLayoutCycle: number;
  65852. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65853. adaptHeightToChildren: boolean;
  65854. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65855. adaptWidthToChildren: boolean;
  65856. /** Gets or sets background color */
  65857. background: string;
  65858. /** Gets the list of children */
  65859. readonly children: Control[];
  65860. /**
  65861. * Creates a new Container
  65862. * @param name defines the name of the container
  65863. */
  65864. constructor(name?: string | undefined);
  65865. protected _getTypeName(): string;
  65866. _flagDescendantsAsMatrixDirty(): void;
  65867. /**
  65868. * Gets a child using its name
  65869. * @param name defines the child name to look for
  65870. * @returns the child control if found
  65871. */
  65872. getChildByName(name: string): BABYLON.Nullable<Control>;
  65873. /**
  65874. * Gets a child using its type and its name
  65875. * @param name defines the child name to look for
  65876. * @param type defines the child type to look for
  65877. * @returns the child control if found
  65878. */
  65879. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65880. /**
  65881. * Search for a specific control in children
  65882. * @param control defines the control to look for
  65883. * @returns true if the control is in child list
  65884. */
  65885. containsControl(control: Control): boolean;
  65886. /**
  65887. * Adds a new control to the current container
  65888. * @param control defines the control to add
  65889. * @returns the current container
  65890. */
  65891. addControl(control: BABYLON.Nullable<Control>): Container;
  65892. /**
  65893. * Removes all controls from the current container
  65894. * @returns the current container
  65895. */
  65896. clearControls(): Container;
  65897. /**
  65898. * Removes a control from the current container
  65899. * @param control defines the control to remove
  65900. * @returns the current container
  65901. */
  65902. removeControl(control: Control): Container;
  65903. /** @hidden */
  65904. _reOrderControl(control: Control): void;
  65905. /** @hidden */
  65906. _offsetLeft(offset: number): void;
  65907. /** @hidden */
  65908. _offsetTop(offset: number): void;
  65909. /** @hidden */
  65910. _markAllAsDirty(): void;
  65911. /** @hidden */
  65912. protected _localDraw(context: CanvasRenderingContext2D): void;
  65913. /** @hidden */
  65914. _link(host: AdvancedDynamicTexture): void;
  65915. /** @hidden */
  65916. protected _beforeLayout(): void;
  65917. /** @hidden */
  65918. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65919. /** @hidden */
  65920. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65921. protected _postMeasure(): void;
  65922. /** @hidden */
  65923. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65924. /** @hidden */
  65925. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65926. /** @hidden */
  65927. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65928. /** @hidden */
  65929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65930. /** Releases associated resources */
  65931. dispose(): void;
  65932. }
  65933. }
  65934. declare module BABYLON.GUI {
  65935. /** Class used to create rectangle container */
  65936. export class Rectangle extends Container {
  65937. name?: string | undefined;
  65938. private _thickness;
  65939. private _cornerRadius;
  65940. /** Gets or sets border thickness */
  65941. thickness: number;
  65942. /** Gets or sets the corner radius angle */
  65943. cornerRadius: number;
  65944. /**
  65945. * Creates a new Rectangle
  65946. * @param name defines the control name
  65947. */
  65948. constructor(name?: string | undefined);
  65949. protected _getTypeName(): string;
  65950. protected _localDraw(context: CanvasRenderingContext2D): void;
  65951. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65952. private _drawRoundedRect;
  65953. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65954. }
  65955. }
  65956. declare module BABYLON.GUI {
  65957. /**
  65958. * Enum that determines the text-wrapping mode to use.
  65959. */
  65960. export enum TextWrapping {
  65961. /**
  65962. * Clip the text when it's larger than Control.width; this is the default mode.
  65963. */
  65964. Clip = 0,
  65965. /**
  65966. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65967. */
  65968. WordWrap = 1,
  65969. /**
  65970. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65971. */
  65972. Ellipsis = 2
  65973. }
  65974. /**
  65975. * Class used to create text block control
  65976. */
  65977. export class TextBlock extends Control {
  65978. /**
  65979. * Defines the name of the control
  65980. */
  65981. name?: string | undefined;
  65982. private _text;
  65983. private _textWrapping;
  65984. private _textHorizontalAlignment;
  65985. private _textVerticalAlignment;
  65986. private _lines;
  65987. private _resizeToFit;
  65988. private _lineSpacing;
  65989. private _outlineWidth;
  65990. private _outlineColor;
  65991. /**
  65992. * An event triggered after the text is changed
  65993. */
  65994. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65995. /**
  65996. * An event triggered after the text was broken up into lines
  65997. */
  65998. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65999. /**
  66000. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  66001. */
  66002. readonly lines: any[];
  66003. /**
  66004. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66005. */
  66006. /**
  66007. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66008. */
  66009. resizeToFit: boolean;
  66010. /**
  66011. * Gets or sets a boolean indicating if text must be wrapped
  66012. */
  66013. /**
  66014. * Gets or sets a boolean indicating if text must be wrapped
  66015. */
  66016. textWrapping: TextWrapping | boolean;
  66017. /**
  66018. * Gets or sets text to display
  66019. */
  66020. /**
  66021. * Gets or sets text to display
  66022. */
  66023. text: string;
  66024. /**
  66025. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66026. */
  66027. /**
  66028. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66029. */
  66030. textHorizontalAlignment: number;
  66031. /**
  66032. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66033. */
  66034. /**
  66035. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66036. */
  66037. textVerticalAlignment: number;
  66038. /**
  66039. * Gets or sets line spacing value
  66040. */
  66041. /**
  66042. * Gets or sets line spacing value
  66043. */
  66044. lineSpacing: string | number;
  66045. /**
  66046. * Gets or sets outlineWidth of the text to display
  66047. */
  66048. /**
  66049. * Gets or sets outlineWidth of the text to display
  66050. */
  66051. outlineWidth: number;
  66052. /**
  66053. * Gets or sets outlineColor of the text to display
  66054. */
  66055. /**
  66056. * Gets or sets outlineColor of the text to display
  66057. */
  66058. outlineColor: string;
  66059. /**
  66060. * Creates a new TextBlock object
  66061. * @param name defines the name of the control
  66062. * @param text defines the text to display (emptry string by default)
  66063. */
  66064. constructor(
  66065. /**
  66066. * Defines the name of the control
  66067. */
  66068. name?: string | undefined, text?: string);
  66069. protected _getTypeName(): string;
  66070. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66071. private _drawText;
  66072. /** @hidden */
  66073. _draw(context: CanvasRenderingContext2D): void;
  66074. protected _applyStates(context: CanvasRenderingContext2D): void;
  66075. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  66076. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  66077. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  66078. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  66079. protected _renderLines(context: CanvasRenderingContext2D): void;
  66080. /**
  66081. * Given a width constraint applied on the text block, find the expected height
  66082. * @returns expected height
  66083. */
  66084. computeExpectedHeight(): number;
  66085. dispose(): void;
  66086. }
  66087. }
  66088. declare module BABYLON.GUI {
  66089. /**
  66090. * Class used to create 2D images
  66091. */
  66092. export class Image extends Control {
  66093. name?: string | undefined;
  66094. private _workingCanvas;
  66095. private _domImage;
  66096. private _imageWidth;
  66097. private _imageHeight;
  66098. private _loaded;
  66099. private _stretch;
  66100. private _source;
  66101. private _autoScale;
  66102. private _sourceLeft;
  66103. private _sourceTop;
  66104. private _sourceWidth;
  66105. private _sourceHeight;
  66106. private _cellWidth;
  66107. private _cellHeight;
  66108. private _cellId;
  66109. private _populateNinePatchSlicesFromImage;
  66110. private _sliceLeft;
  66111. private _sliceRight;
  66112. private _sliceTop;
  66113. private _sliceBottom;
  66114. private _detectPointerOnOpaqueOnly;
  66115. /**
  66116. * BABYLON.Observable notified when the content is loaded
  66117. */
  66118. onImageLoadedObservable: BABYLON.Observable<Image>;
  66119. /**
  66120. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  66121. */
  66122. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  66123. /**
  66124. * Gets a boolean indicating that the content is loaded
  66125. */
  66126. readonly isLoaded: boolean;
  66127. /**
  66128. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  66129. */
  66130. populateNinePatchSlicesFromImage: boolean;
  66131. /**
  66132. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  66133. * Beware using this as this will comsume more memory as the image has to be stored twice
  66134. */
  66135. detectPointerOnOpaqueOnly: boolean;
  66136. /**
  66137. * Gets or sets the left value for slicing (9-patch)
  66138. */
  66139. sliceLeft: number;
  66140. /**
  66141. * Gets or sets the right value for slicing (9-patch)
  66142. */
  66143. sliceRight: number;
  66144. /**
  66145. * Gets or sets the top value for slicing (9-patch)
  66146. */
  66147. sliceTop: number;
  66148. /**
  66149. * Gets or sets the bottom value for slicing (9-patch)
  66150. */
  66151. sliceBottom: number;
  66152. /**
  66153. * Gets or sets the left coordinate in the source image
  66154. */
  66155. sourceLeft: number;
  66156. /**
  66157. * Gets or sets the top coordinate in the source image
  66158. */
  66159. sourceTop: number;
  66160. /**
  66161. * Gets or sets the width to capture in the source image
  66162. */
  66163. sourceWidth: number;
  66164. /**
  66165. * Gets or sets the height to capture in the source image
  66166. */
  66167. sourceHeight: number;
  66168. /**
  66169. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  66170. * @see http://doc.babylonjs.com/how_to/gui#image
  66171. */
  66172. autoScale: boolean;
  66173. /** Gets or sets the streching mode used by the image */
  66174. stretch: number;
  66175. /**
  66176. * Gets or sets the internal DOM image used to render the control
  66177. */
  66178. domImage: HTMLImageElement;
  66179. private _onImageLoaded;
  66180. private _extractNinePatchSliceDataFromImage;
  66181. /**
  66182. * Gets or sets image source url
  66183. */
  66184. source: BABYLON.Nullable<string>;
  66185. /**
  66186. * Checks for svg document with icon id present
  66187. */
  66188. private _svgCheck;
  66189. /**
  66190. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  66191. * given external svg file and icon id
  66192. */
  66193. private _getSVGAttribs;
  66194. /**
  66195. * Gets or sets the cell width to use when animation sheet is enabled
  66196. * @see http://doc.babylonjs.com/how_to/gui#image
  66197. */
  66198. cellWidth: number;
  66199. /**
  66200. * Gets or sets the cell height to use when animation sheet is enabled
  66201. * @see http://doc.babylonjs.com/how_to/gui#image
  66202. */
  66203. cellHeight: number;
  66204. /**
  66205. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  66206. * @see http://doc.babylonjs.com/how_to/gui#image
  66207. */
  66208. cellId: number;
  66209. /**
  66210. * Creates a new Image
  66211. * @param name defines the control name
  66212. * @param url defines the image url
  66213. */
  66214. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  66215. /**
  66216. * Tests if a given coordinates belong to the current control
  66217. * @param x defines x coordinate to test
  66218. * @param y defines y coordinate to test
  66219. * @returns true if the coordinates are inside the control
  66220. */
  66221. contains(x: number, y: number): boolean;
  66222. protected _getTypeName(): string;
  66223. /** Force the control to synchronize with its content */
  66224. synchronizeSizeWithContent(): void;
  66225. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66226. private _prepareWorkingCanvasForOpaqueDetection;
  66227. private _drawImage;
  66228. _draw(context: CanvasRenderingContext2D): void;
  66229. private _renderCornerPatch;
  66230. private _renderNinePatch;
  66231. dispose(): void;
  66232. /** STRETCH_NONE */
  66233. static readonly STRETCH_NONE: number;
  66234. /** STRETCH_FILL */
  66235. static readonly STRETCH_FILL: number;
  66236. /** STRETCH_UNIFORM */
  66237. static readonly STRETCH_UNIFORM: number;
  66238. /** STRETCH_EXTEND */
  66239. static readonly STRETCH_EXTEND: number;
  66240. /** NINE_PATCH */
  66241. static readonly STRETCH_NINE_PATCH: number;
  66242. }
  66243. }
  66244. declare module BABYLON.GUI {
  66245. /**
  66246. * Class used to create 2D buttons
  66247. */
  66248. export class Button extends Rectangle {
  66249. name?: string | undefined;
  66250. /**
  66251. * Function called to generate a pointer enter animation
  66252. */
  66253. pointerEnterAnimation: () => void;
  66254. /**
  66255. * Function called to generate a pointer out animation
  66256. */
  66257. pointerOutAnimation: () => void;
  66258. /**
  66259. * Function called to generate a pointer down animation
  66260. */
  66261. pointerDownAnimation: () => void;
  66262. /**
  66263. * Function called to generate a pointer up animation
  66264. */
  66265. pointerUpAnimation: () => void;
  66266. /**
  66267. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  66268. */
  66269. delegatePickingToChildren: boolean;
  66270. private _image;
  66271. /**
  66272. * Returns the image part of the button (if any)
  66273. */
  66274. readonly image: BABYLON.Nullable<Image>;
  66275. private _textBlock;
  66276. /**
  66277. * Returns the image part of the button (if any)
  66278. */
  66279. readonly textBlock: BABYLON.Nullable<TextBlock>;
  66280. /**
  66281. * Creates a new Button
  66282. * @param name defines the name of the button
  66283. */
  66284. constructor(name?: string | undefined);
  66285. protected _getTypeName(): string;
  66286. /** @hidden */
  66287. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66288. /** @hidden */
  66289. _onPointerEnter(target: Control): boolean;
  66290. /** @hidden */
  66291. _onPointerOut(target: Control, force?: boolean): void;
  66292. /** @hidden */
  66293. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66294. /** @hidden */
  66295. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66296. /**
  66297. * Creates a new button made with an image and a text
  66298. * @param name defines the name of the button
  66299. * @param text defines the text of the button
  66300. * @param imageUrl defines the url of the image
  66301. * @returns a new Button
  66302. */
  66303. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  66304. /**
  66305. * Creates a new button made with an image
  66306. * @param name defines the name of the button
  66307. * @param imageUrl defines the url of the image
  66308. * @returns a new Button
  66309. */
  66310. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66311. /**
  66312. * Creates a new button made with a text
  66313. * @param name defines the name of the button
  66314. * @param text defines the text of the button
  66315. * @returns a new Button
  66316. */
  66317. static CreateSimpleButton(name: string, text: string): Button;
  66318. /**
  66319. * Creates a new button made with an image and a centered text
  66320. * @param name defines the name of the button
  66321. * @param text defines the text of the button
  66322. * @param imageUrl defines the url of the image
  66323. * @returns a new Button
  66324. */
  66325. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66326. }
  66327. }
  66328. declare module BABYLON.GUI {
  66329. /**
  66330. * Class used to create a 2D stack panel container
  66331. */
  66332. export class StackPanel extends Container {
  66333. name?: string | undefined;
  66334. private _isVertical;
  66335. private _manualWidth;
  66336. private _manualHeight;
  66337. private _doNotTrackManualChanges;
  66338. /**
  66339. * Gets or sets a boolean indicating that layou warnings should be ignored
  66340. */
  66341. ignoreLayoutWarnings: boolean;
  66342. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66343. isVertical: boolean;
  66344. /**
  66345. * Gets or sets panel width.
  66346. * This value should not be set when in horizontal mode as it will be computed automatically
  66347. */
  66348. width: string | number;
  66349. /**
  66350. * Gets or sets panel height.
  66351. * This value should not be set when in vertical mode as it will be computed automatically
  66352. */
  66353. height: string | number;
  66354. /**
  66355. * Creates a new StackPanel
  66356. * @param name defines control name
  66357. */
  66358. constructor(name?: string | undefined);
  66359. protected _getTypeName(): string;
  66360. /** @hidden */
  66361. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66362. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66363. protected _postMeasure(): void;
  66364. }
  66365. }
  66366. declare module BABYLON.GUI {
  66367. /**
  66368. * Class used to represent a 2D checkbox
  66369. */
  66370. export class Checkbox extends Control {
  66371. name?: string | undefined;
  66372. private _isChecked;
  66373. private _background;
  66374. private _checkSizeRatio;
  66375. private _thickness;
  66376. /** Gets or sets border thickness */
  66377. thickness: number;
  66378. /**
  66379. * BABYLON.Observable raised when isChecked property changes
  66380. */
  66381. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66382. /** Gets or sets a value indicating the ratio between overall size and check size */
  66383. checkSizeRatio: number;
  66384. /** Gets or sets background color */
  66385. background: string;
  66386. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66387. isChecked: boolean;
  66388. /**
  66389. * Creates a new CheckBox
  66390. * @param name defines the control name
  66391. */
  66392. constructor(name?: string | undefined);
  66393. protected _getTypeName(): string;
  66394. /** @hidden */
  66395. _draw(context: CanvasRenderingContext2D): void;
  66396. /** @hidden */
  66397. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66398. /**
  66399. * Utility function to easily create a checkbox with a header
  66400. * @param title defines the label to use for the header
  66401. * @param onValueChanged defines the callback to call when value changes
  66402. * @returns a StackPanel containing the checkbox and a textBlock
  66403. */
  66404. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66405. }
  66406. }
  66407. declare module BABYLON.GUI {
  66408. /**
  66409. * Class used to store key control properties
  66410. */
  66411. export class KeyPropertySet {
  66412. /** Width */
  66413. width?: string;
  66414. /** Height */
  66415. height?: string;
  66416. /** Left padding */
  66417. paddingLeft?: string;
  66418. /** Right padding */
  66419. paddingRight?: string;
  66420. /** Top padding */
  66421. paddingTop?: string;
  66422. /** Bottom padding */
  66423. paddingBottom?: string;
  66424. /** Foreground color */
  66425. color?: string;
  66426. /** Background color */
  66427. background?: string;
  66428. }
  66429. /**
  66430. * Class used to create virtual keyboard
  66431. */
  66432. export class VirtualKeyboard extends StackPanel {
  66433. /** BABYLON.Observable raised when a key is pressed */
  66434. onKeyPressObservable: BABYLON.Observable<string>;
  66435. /** Gets or sets default key button width */
  66436. defaultButtonWidth: string;
  66437. /** Gets or sets default key button height */
  66438. defaultButtonHeight: string;
  66439. /** Gets or sets default key button left padding */
  66440. defaultButtonPaddingLeft: string;
  66441. /** Gets or sets default key button right padding */
  66442. defaultButtonPaddingRight: string;
  66443. /** Gets or sets default key button top padding */
  66444. defaultButtonPaddingTop: string;
  66445. /** Gets or sets default key button bottom padding */
  66446. defaultButtonPaddingBottom: string;
  66447. /** Gets or sets default key button foreground color */
  66448. defaultButtonColor: string;
  66449. /** Gets or sets default key button background color */
  66450. defaultButtonBackground: string;
  66451. /** Gets or sets shift button foreground color */
  66452. shiftButtonColor: string;
  66453. /** Gets or sets shift button thickness*/
  66454. selectedShiftThickness: number;
  66455. /** Gets shift key state */
  66456. shiftState: number;
  66457. protected _getTypeName(): string;
  66458. private _createKey;
  66459. /**
  66460. * Adds a new row of keys
  66461. * @param keys defines the list of keys to add
  66462. * @param propertySets defines the associated property sets
  66463. */
  66464. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66465. /**
  66466. * Set the shift key to a specific state
  66467. * @param shiftState defines the new shift state
  66468. */
  66469. applyShiftState(shiftState: number): void;
  66470. private _currentlyConnectedInputText;
  66471. private _connectedInputTexts;
  66472. private _onKeyPressObserver;
  66473. /** Gets the input text control currently attached to the keyboard */
  66474. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66475. /**
  66476. * Connects the keyboard with an input text control
  66477. *
  66478. * @param input defines the target control
  66479. */
  66480. connect(input: InputText): void;
  66481. /**
  66482. * Disconnects the keyboard from connected InputText controls
  66483. *
  66484. * @param input optionally defines a target control, otherwise all are disconnected
  66485. */
  66486. disconnect(input?: InputText): void;
  66487. private _removeConnectedInputObservables;
  66488. /**
  66489. * Release all resources
  66490. */
  66491. dispose(): void;
  66492. /**
  66493. * Creates a new keyboard using a default layout
  66494. *
  66495. * @param name defines control name
  66496. * @returns a new VirtualKeyboard
  66497. */
  66498. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66499. }
  66500. }
  66501. declare module BABYLON.GUI {
  66502. /**
  66503. * Class used to create input text control
  66504. */
  66505. export class InputText extends Control implements IFocusableControl {
  66506. name?: string | undefined;
  66507. private _text;
  66508. private _placeholderText;
  66509. private _background;
  66510. private _focusedBackground;
  66511. private _focusedColor;
  66512. private _placeholderColor;
  66513. private _thickness;
  66514. private _margin;
  66515. private _autoStretchWidth;
  66516. private _maxWidth;
  66517. private _isFocused;
  66518. private _blinkTimeout;
  66519. private _blinkIsEven;
  66520. private _cursorOffset;
  66521. private _scrollLeft;
  66522. private _textWidth;
  66523. private _clickedCoordinate;
  66524. private _deadKey;
  66525. private _addKey;
  66526. private _currentKey;
  66527. private _isTextHighlightOn;
  66528. private _textHighlightColor;
  66529. private _highligherOpacity;
  66530. private _highlightedText;
  66531. private _startHighlightIndex;
  66532. private _endHighlightIndex;
  66533. private _cursorIndex;
  66534. private _onFocusSelectAll;
  66535. private _isPointerDown;
  66536. private _onClipboardObserver;
  66537. private _onPointerDblTapObserver;
  66538. /** @hidden */
  66539. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66540. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66541. promptMessage: string;
  66542. /** Force disable prompt on mobile device */
  66543. disableMobilePrompt: boolean;
  66544. /** BABYLON.Observable raised when the text changes */
  66545. onTextChangedObservable: BABYLON.Observable<InputText>;
  66546. /** BABYLON.Observable raised just before an entered character is to be added */
  66547. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66548. /** BABYLON.Observable raised when the control gets the focus */
  66549. onFocusObservable: BABYLON.Observable<InputText>;
  66550. /** BABYLON.Observable raised when the control loses the focus */
  66551. onBlurObservable: BABYLON.Observable<InputText>;
  66552. /**Observable raised when the text is highlighted */
  66553. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66554. /**Observable raised when copy event is triggered */
  66555. onTextCopyObservable: BABYLON.Observable<InputText>;
  66556. /** BABYLON.Observable raised when cut event is triggered */
  66557. onTextCutObservable: BABYLON.Observable<InputText>;
  66558. /** BABYLON.Observable raised when paste event is triggered */
  66559. onTextPasteObservable: BABYLON.Observable<InputText>;
  66560. /** BABYLON.Observable raised when a key event was processed */
  66561. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66562. /** Gets or sets the maximum width allowed by the control */
  66563. maxWidth: string | number;
  66564. /** Gets the maximum width allowed by the control in pixels */
  66565. readonly maxWidthInPixels: number;
  66566. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66567. highligherOpacity: number;
  66568. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66569. onFocusSelectAll: boolean;
  66570. /** Gets or sets the text hightlight color */
  66571. textHighlightColor: string;
  66572. /** Gets or sets control margin */
  66573. margin: string;
  66574. /** Gets control margin in pixels */
  66575. readonly marginInPixels: number;
  66576. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66577. autoStretchWidth: boolean;
  66578. /** Gets or sets border thickness */
  66579. thickness: number;
  66580. /** Gets or sets the background color when focused */
  66581. focusedBackground: string;
  66582. /** Gets or sets the background color when focused */
  66583. focusedColor: string;
  66584. /** Gets or sets the background color */
  66585. background: string;
  66586. /** Gets or sets the placeholder color */
  66587. placeholderColor: string;
  66588. /** Gets or sets the text displayed when the control is empty */
  66589. placeholderText: string;
  66590. /** Gets or sets the dead key flag */
  66591. deadKey: boolean;
  66592. /** Gets or sets the highlight text */
  66593. highlightedText: string;
  66594. /** Gets or sets if the current key should be added */
  66595. addKey: boolean;
  66596. /** Gets or sets the value of the current key being entered */
  66597. currentKey: string;
  66598. /** Gets or sets the text displayed in the control */
  66599. text: string;
  66600. /** Gets or sets control width */
  66601. width: string | number;
  66602. /**
  66603. * Creates a new InputText
  66604. * @param name defines the control name
  66605. * @param text defines the text of the control
  66606. */
  66607. constructor(name?: string | undefined, text?: string);
  66608. /** @hidden */
  66609. onBlur(): void;
  66610. /** @hidden */
  66611. onFocus(): void;
  66612. protected _getTypeName(): string;
  66613. /**
  66614. * Function called to get the list of controls that should not steal the focus from this control
  66615. * @returns an array of controls
  66616. */
  66617. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66618. /** @hidden */
  66619. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66620. /** @hidden */
  66621. private _updateValueFromCursorIndex;
  66622. /** @hidden */
  66623. private _processDblClick;
  66624. /** @hidden */
  66625. private _selectAllText;
  66626. /**
  66627. * Handles the keyboard event
  66628. * @param evt Defines the KeyboardEvent
  66629. */
  66630. processKeyboard(evt: KeyboardEvent): void;
  66631. /** @hidden */
  66632. private _onCopyText;
  66633. /** @hidden */
  66634. private _onCutText;
  66635. /** @hidden */
  66636. private _onPasteText;
  66637. _draw(context: CanvasRenderingContext2D): void;
  66638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66639. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66640. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66641. protected _beforeRenderText(text: string): string;
  66642. dispose(): void;
  66643. }
  66644. }
  66645. declare module BABYLON.GUI {
  66646. /**
  66647. * Class used to create a 2D grid container
  66648. */
  66649. export class Grid extends Container {
  66650. name?: string | undefined;
  66651. private _rowDefinitions;
  66652. private _columnDefinitions;
  66653. private _cells;
  66654. private _childControls;
  66655. /**
  66656. * Gets the number of columns
  66657. */
  66658. readonly columnCount: number;
  66659. /**
  66660. * Gets the number of rows
  66661. */
  66662. readonly rowCount: number;
  66663. /** Gets the list of children */
  66664. readonly children: Control[];
  66665. /** Gets the list of cells (e.g. the containers) */
  66666. readonly cells: {
  66667. [key: string]: Container;
  66668. };
  66669. /**
  66670. * Gets the definition of a specific row
  66671. * @param index defines the index of the row
  66672. * @returns the row definition
  66673. */
  66674. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66675. /**
  66676. * Gets the definition of a specific column
  66677. * @param index defines the index of the column
  66678. * @returns the column definition
  66679. */
  66680. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66681. /**
  66682. * Adds a new row to the grid
  66683. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66684. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66685. * @returns the current grid
  66686. */
  66687. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66688. /**
  66689. * Adds a new column to the grid
  66690. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66691. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66692. * @returns the current grid
  66693. */
  66694. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66695. /**
  66696. * Update a row definition
  66697. * @param index defines the index of the row to update
  66698. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66699. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66700. * @returns the current grid
  66701. */
  66702. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66703. /**
  66704. * Update a column definition
  66705. * @param index defines the index of the column to update
  66706. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66707. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66708. * @returns the current grid
  66709. */
  66710. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66711. /**
  66712. * Gets the list of children stored in a specific cell
  66713. * @param row defines the row to check
  66714. * @param column defines the column to check
  66715. * @returns the list of controls
  66716. */
  66717. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66718. /**
  66719. * Gets a string representing the child cell info (row x column)
  66720. * @param child defines the control to get info from
  66721. * @returns a string containing the child cell info (row x column)
  66722. */
  66723. getChildCellInfo(child: Control): string;
  66724. private _removeCell;
  66725. private _offsetCell;
  66726. /**
  66727. * Remove a column definition at specified index
  66728. * @param index defines the index of the column to remove
  66729. * @returns the current grid
  66730. */
  66731. removeColumnDefinition(index: number): Grid;
  66732. /**
  66733. * Remove a row definition at specified index
  66734. * @param index defines the index of the row to remove
  66735. * @returns the current grid
  66736. */
  66737. removeRowDefinition(index: number): Grid;
  66738. /**
  66739. * Adds a new control to the current grid
  66740. * @param control defines the control to add
  66741. * @param row defines the row where to add the control (0 by default)
  66742. * @param column defines the column where to add the control (0 by default)
  66743. * @returns the current grid
  66744. */
  66745. addControl(control: Control, row?: number, column?: number): Grid;
  66746. /**
  66747. * Removes a control from the current container
  66748. * @param control defines the control to remove
  66749. * @returns the current container
  66750. */
  66751. removeControl(control: Control): Container;
  66752. /**
  66753. * Creates a new Grid
  66754. * @param name defines control name
  66755. */
  66756. constructor(name?: string | undefined);
  66757. protected _getTypeName(): string;
  66758. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66759. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66760. _flagDescendantsAsMatrixDirty(): void;
  66761. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66762. /** Releases associated resources */
  66763. dispose(): void;
  66764. }
  66765. }
  66766. declare module BABYLON.GUI {
  66767. /** Class used to create color pickers */
  66768. export class ColorPicker extends Control {
  66769. name?: string | undefined;
  66770. private static _Epsilon;
  66771. private _colorWheelCanvas;
  66772. private _value;
  66773. private _tmpColor;
  66774. private _pointerStartedOnSquare;
  66775. private _pointerStartedOnWheel;
  66776. private _squareLeft;
  66777. private _squareTop;
  66778. private _squareSize;
  66779. private _h;
  66780. private _s;
  66781. private _v;
  66782. private _lastPointerDownID;
  66783. /**
  66784. * BABYLON.Observable raised when the value changes
  66785. */
  66786. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66787. /** Gets or sets the color of the color picker */
  66788. value: BABYLON.Color3;
  66789. /**
  66790. * Gets or sets control width
  66791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66792. */
  66793. width: string | number;
  66794. /**
  66795. * Gets or sets control height
  66796. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66797. */
  66798. /** Gets or sets control height */
  66799. height: string | number;
  66800. /** Gets or sets control size */
  66801. size: string | number;
  66802. /**
  66803. * Creates a new ColorPicker
  66804. * @param name defines the control name
  66805. */
  66806. constructor(name?: string | undefined);
  66807. protected _getTypeName(): string;
  66808. /** @hidden */
  66809. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66810. private _updateSquareProps;
  66811. private _drawGradientSquare;
  66812. private _drawCircle;
  66813. private _createColorWheelCanvas;
  66814. /** @hidden */
  66815. _draw(context: CanvasRenderingContext2D): void;
  66816. private _pointerIsDown;
  66817. private _updateValueFromPointer;
  66818. private _isPointOnSquare;
  66819. private _isPointOnWheel;
  66820. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66821. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66822. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66823. /**
  66824. * This function expands the color picker by creating a color picker dialog with manual
  66825. * color value input and the ability to save colors into an array to be used later in
  66826. * subsequent launches of the dialogue.
  66827. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66828. * @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.
  66829. * @returns picked color as a hex string and the saved colors array as hex strings.
  66830. */
  66831. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66832. pickerWidth?: string;
  66833. pickerHeight?: string;
  66834. headerHeight?: string;
  66835. lastColor?: string;
  66836. swatchLimit?: number;
  66837. numSwatchesPerLine?: number;
  66838. savedColors?: Array<string>;
  66839. }): Promise<{
  66840. savedColors?: string[];
  66841. pickedColor: string;
  66842. }>;
  66843. }
  66844. }
  66845. declare module BABYLON.GUI {
  66846. /** Class used to create 2D ellipse containers */
  66847. export class Ellipse extends Container {
  66848. name?: string | undefined;
  66849. private _thickness;
  66850. /** Gets or sets border thickness */
  66851. thickness: number;
  66852. /**
  66853. * Creates a new Ellipse
  66854. * @param name defines the control name
  66855. */
  66856. constructor(name?: string | undefined);
  66857. protected _getTypeName(): string;
  66858. protected _localDraw(context: CanvasRenderingContext2D): void;
  66859. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66860. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66861. }
  66862. }
  66863. declare module BABYLON.GUI {
  66864. /**
  66865. * Class used to create a password control
  66866. */
  66867. export class InputPassword extends InputText {
  66868. protected _beforeRenderText(text: string): string;
  66869. }
  66870. }
  66871. declare module BABYLON.GUI {
  66872. /** Class used to render 2D lines */
  66873. export class Line extends Control {
  66874. name?: string | undefined;
  66875. private _lineWidth;
  66876. private _x1;
  66877. private _y1;
  66878. private _x2;
  66879. private _y2;
  66880. private _dash;
  66881. private _connectedControl;
  66882. private _connectedControlDirtyObserver;
  66883. /** Gets or sets the dash pattern */
  66884. dash: Array<number>;
  66885. /** Gets or sets the control connected with the line end */
  66886. connectedControl: Control;
  66887. /** Gets or sets start coordinates on X axis */
  66888. x1: string | number;
  66889. /** Gets or sets start coordinates on Y axis */
  66890. y1: string | number;
  66891. /** Gets or sets end coordinates on X axis */
  66892. x2: string | number;
  66893. /** Gets or sets end coordinates on Y axis */
  66894. y2: string | number;
  66895. /** Gets or sets line width */
  66896. lineWidth: number;
  66897. /** Gets or sets horizontal alignment */
  66898. horizontalAlignment: number;
  66899. /** Gets or sets vertical alignment */
  66900. verticalAlignment: number;
  66901. private readonly _effectiveX2;
  66902. private readonly _effectiveY2;
  66903. /**
  66904. * Creates a new Line
  66905. * @param name defines the control name
  66906. */
  66907. constructor(name?: string | undefined);
  66908. protected _getTypeName(): string;
  66909. _draw(context: CanvasRenderingContext2D): void;
  66910. _measure(): void;
  66911. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66912. /**
  66913. * Move one end of the line given 3D cartesian coordinates.
  66914. * @param position Targeted world position
  66915. * @param scene BABYLON.Scene
  66916. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66917. */
  66918. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66919. /**
  66920. * Move one end of the line to a position in screen absolute space.
  66921. * @param projectedPosition Position in screen absolute space (X, Y)
  66922. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66923. */
  66924. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66925. }
  66926. }
  66927. declare module BABYLON.GUI {
  66928. /**
  66929. * Class used to store a point for a MultiLine object.
  66930. * The point can be pure 2D coordinates, a mesh or a control
  66931. */
  66932. export class MultiLinePoint {
  66933. private _multiLine;
  66934. private _x;
  66935. private _y;
  66936. private _control;
  66937. private _mesh;
  66938. private _controlObserver;
  66939. private _meshObserver;
  66940. /** @hidden */
  66941. _point: BABYLON.Vector2;
  66942. /**
  66943. * Creates a new MultiLinePoint
  66944. * @param multiLine defines the source MultiLine object
  66945. */
  66946. constructor(multiLine: MultiLine);
  66947. /** Gets or sets x coordinate */
  66948. x: string | number;
  66949. /** Gets or sets y coordinate */
  66950. y: string | number;
  66951. /** Gets or sets the control associated with this point */
  66952. control: BABYLON.Nullable<Control>;
  66953. /** Gets or sets the mesh associated with this point */
  66954. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66955. /** Resets links */
  66956. resetLinks(): void;
  66957. /**
  66958. * Gets a translation vector
  66959. * @returns the translation vector
  66960. */
  66961. translate(): BABYLON.Vector2;
  66962. private _translatePoint;
  66963. /** Release associated resources */
  66964. dispose(): void;
  66965. }
  66966. }
  66967. declare module BABYLON.GUI {
  66968. /**
  66969. * Class used to create multi line control
  66970. */
  66971. export class MultiLine extends Control {
  66972. name?: string | undefined;
  66973. private _lineWidth;
  66974. private _dash;
  66975. private _points;
  66976. private _minX;
  66977. private _minY;
  66978. private _maxX;
  66979. private _maxY;
  66980. /**
  66981. * Creates a new MultiLine
  66982. * @param name defines the control name
  66983. */
  66984. constructor(name?: string | undefined);
  66985. /** Gets or sets dash pattern */
  66986. dash: Array<number>;
  66987. /**
  66988. * Gets point stored at specified index
  66989. * @param index defines the index to look for
  66990. * @returns the requested point if found
  66991. */
  66992. getAt(index: number): MultiLinePoint;
  66993. /** Function called when a point is updated */
  66994. onPointUpdate: () => void;
  66995. /**
  66996. * Adds new points to the point collection
  66997. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66998. * @returns the list of created MultiLinePoint
  66999. */
  67000. add(...items: (AbstractMesh | Control | {
  67001. x: string | number;
  67002. y: string | number;
  67003. })[]): MultiLinePoint[];
  67004. /**
  67005. * Adds a new point to the point collection
  67006. * @param item defines the item (mesh, control or 2d coordiantes) to add
  67007. * @returns the created MultiLinePoint
  67008. */
  67009. push(item?: (AbstractMesh | Control | {
  67010. x: string | number;
  67011. y: string | number;
  67012. })): MultiLinePoint;
  67013. /**
  67014. * Remove a specific value or point from the active point collection
  67015. * @param value defines the value or point to remove
  67016. */
  67017. remove(value: number | MultiLinePoint): void;
  67018. /**
  67019. * Resets this object to initial state (no point)
  67020. */
  67021. reset(): void;
  67022. /**
  67023. * Resets all links
  67024. */
  67025. resetLinks(): void;
  67026. /** Gets or sets line width */
  67027. lineWidth: number;
  67028. horizontalAlignment: number;
  67029. verticalAlignment: number;
  67030. protected _getTypeName(): string;
  67031. _draw(context: CanvasRenderingContext2D): void;
  67032. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67033. _measure(): void;
  67034. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67035. dispose(): void;
  67036. }
  67037. }
  67038. declare module BABYLON.GUI {
  67039. /**
  67040. * Class used to create radio button controls
  67041. */
  67042. export class RadioButton extends Control {
  67043. name?: string | undefined;
  67044. private _isChecked;
  67045. private _background;
  67046. private _checkSizeRatio;
  67047. private _thickness;
  67048. /** Gets or sets border thickness */
  67049. thickness: number;
  67050. /** Gets or sets group name */
  67051. group: string;
  67052. /** BABYLON.Observable raised when isChecked is changed */
  67053. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67054. /** Gets or sets a value indicating the ratio between overall size and check size */
  67055. checkSizeRatio: number;
  67056. /** Gets or sets background color */
  67057. background: string;
  67058. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67059. isChecked: boolean;
  67060. /**
  67061. * Creates a new RadioButton
  67062. * @param name defines the control name
  67063. */
  67064. constructor(name?: string | undefined);
  67065. protected _getTypeName(): string;
  67066. _draw(context: CanvasRenderingContext2D): void;
  67067. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67068. /**
  67069. * Utility function to easily create a radio button with a header
  67070. * @param title defines the label to use for the header
  67071. * @param group defines the group to use for the radio button
  67072. * @param isChecked defines the initial state of the radio button
  67073. * @param onValueChanged defines the callback to call when value changes
  67074. * @returns a StackPanel containing the radio button and a textBlock
  67075. */
  67076. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  67077. }
  67078. }
  67079. declare module BABYLON.GUI {
  67080. /**
  67081. * Class used to create slider controls
  67082. */
  67083. export class BaseSlider extends Control {
  67084. name?: string | undefined;
  67085. protected _thumbWidth: ValueAndUnit;
  67086. private _minimum;
  67087. private _maximum;
  67088. private _value;
  67089. private _isVertical;
  67090. protected _barOffset: ValueAndUnit;
  67091. private _isThumbClamped;
  67092. protected _displayThumb: boolean;
  67093. private _step;
  67094. private _lastPointerDownID;
  67095. protected _effectiveBarOffset: number;
  67096. protected _renderLeft: number;
  67097. protected _renderTop: number;
  67098. protected _renderWidth: number;
  67099. protected _renderHeight: number;
  67100. protected _backgroundBoxLength: number;
  67101. protected _backgroundBoxThickness: number;
  67102. protected _effectiveThumbThickness: number;
  67103. /** BABYLON.Observable raised when the sldier value changes */
  67104. onValueChangedObservable: BABYLON.Observable<number>;
  67105. /** Gets or sets a boolean indicating if the thumb must be rendered */
  67106. displayThumb: boolean;
  67107. /** Gets or sets a step to apply to values (0 by default) */
  67108. step: number;
  67109. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  67110. barOffset: string | number;
  67111. /** Gets main bar offset in pixels*/
  67112. readonly barOffsetInPixels: number;
  67113. /** Gets or sets thumb width */
  67114. thumbWidth: string | number;
  67115. /** Gets thumb width in pixels */
  67116. readonly thumbWidthInPixels: number;
  67117. /** Gets or sets minimum value */
  67118. minimum: number;
  67119. /** Gets or sets maximum value */
  67120. maximum: number;
  67121. /** Gets or sets current value */
  67122. value: number;
  67123. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  67124. isVertical: boolean;
  67125. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  67126. isThumbClamped: boolean;
  67127. /**
  67128. * Creates a new BaseSlider
  67129. * @param name defines the control name
  67130. */
  67131. constructor(name?: string | undefined);
  67132. protected _getTypeName(): string;
  67133. protected _getThumbPosition(): number;
  67134. protected _getThumbThickness(type: string): number;
  67135. protected _prepareRenderingData(type: string): void;
  67136. private _pointerIsDown;
  67137. /** @hidden */
  67138. protected _updateValueFromPointer(x: number, y: number): void;
  67139. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67140. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67141. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67142. }
  67143. }
  67144. declare module BABYLON.GUI {
  67145. /**
  67146. * Class used to create slider controls
  67147. */
  67148. export class Slider extends BaseSlider {
  67149. name?: string | undefined;
  67150. private _background;
  67151. private _borderColor;
  67152. private _isThumbCircle;
  67153. protected _displayValueBar: boolean;
  67154. /** Gets or sets a boolean indicating if the value bar must be rendered */
  67155. displayValueBar: boolean;
  67156. /** Gets or sets border color */
  67157. borderColor: string;
  67158. /** Gets or sets background color */
  67159. background: string;
  67160. /** Gets or sets a boolean indicating if the thumb should be round or square */
  67161. isThumbCircle: boolean;
  67162. /**
  67163. * Creates a new Slider
  67164. * @param name defines the control name
  67165. */
  67166. constructor(name?: string | undefined);
  67167. protected _getTypeName(): string;
  67168. _draw(context: CanvasRenderingContext2D): void;
  67169. }
  67170. }
  67171. declare module BABYLON.GUI {
  67172. /** Class used to create a RadioGroup
  67173. * which contains groups of radio buttons
  67174. */
  67175. export class SelectorGroup {
  67176. /** name of SelectorGroup */
  67177. name: string;
  67178. private _groupPanel;
  67179. private _selectors;
  67180. private _groupHeader;
  67181. /**
  67182. * Creates a new SelectorGroup
  67183. * @param name of group, used as a group heading
  67184. */
  67185. constructor(
  67186. /** name of SelectorGroup */
  67187. name: string);
  67188. /** Gets the groupPanel of the SelectorGroup */
  67189. readonly groupPanel: StackPanel;
  67190. /** Gets the selectors array */
  67191. readonly selectors: StackPanel[];
  67192. /** Gets and sets the group header */
  67193. header: string;
  67194. /** @hidden */
  67195. private _addGroupHeader;
  67196. /** @hidden*/
  67197. _getSelector(selectorNb: number): StackPanel | undefined;
  67198. /** Removes the selector at the given position
  67199. * @param selectorNb the position of the selector within the group
  67200. */
  67201. removeSelector(selectorNb: number): void;
  67202. }
  67203. /** Class used to create a CheckboxGroup
  67204. * which contains groups of checkbox buttons
  67205. */
  67206. export class CheckboxGroup extends SelectorGroup {
  67207. /** Adds a checkbox as a control
  67208. * @param text is the label for the selector
  67209. * @param func is the function called when the Selector is checked
  67210. * @param checked is true when Selector is checked
  67211. */
  67212. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  67213. /** @hidden */
  67214. _setSelectorLabel(selectorNb: number, label: string): void;
  67215. /** @hidden */
  67216. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67217. /** @hidden */
  67218. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67219. /** @hidden */
  67220. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67221. }
  67222. /** Class used to create a RadioGroup
  67223. * which contains groups of radio buttons
  67224. */
  67225. export class RadioGroup extends SelectorGroup {
  67226. private _selectNb;
  67227. /** Adds a radio button as a control
  67228. * @param label is the label for the selector
  67229. * @param func is the function called when the Selector is checked
  67230. * @param checked is true when Selector is checked
  67231. */
  67232. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  67233. /** @hidden */
  67234. _setSelectorLabel(selectorNb: number, label: string): void;
  67235. /** @hidden */
  67236. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67237. /** @hidden */
  67238. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67239. /** @hidden */
  67240. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67241. }
  67242. /** Class used to create a SliderGroup
  67243. * which contains groups of slider buttons
  67244. */
  67245. export class SliderGroup extends SelectorGroup {
  67246. /**
  67247. * Adds a slider to the SelectorGroup
  67248. * @param label is the label for the SliderBar
  67249. * @param func is the function called when the Slider moves
  67250. * @param unit is a string describing the units used, eg degrees or metres
  67251. * @param min is the minimum value for the Slider
  67252. * @param max is the maximum value for the Slider
  67253. * @param value is the start value for the Slider between min and max
  67254. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  67255. */
  67256. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  67257. /** @hidden */
  67258. _setSelectorLabel(selectorNb: number, label: string): void;
  67259. /** @hidden */
  67260. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67261. /** @hidden */
  67262. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67263. /** @hidden */
  67264. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67265. }
  67266. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  67267. * @see http://doc.babylonjs.com/how_to/selector
  67268. */
  67269. export class SelectionPanel extends Rectangle {
  67270. /** name of SelectionPanel */
  67271. name: string;
  67272. /** an array of SelectionGroups */
  67273. groups: SelectorGroup[];
  67274. private _panel;
  67275. private _buttonColor;
  67276. private _buttonBackground;
  67277. private _headerColor;
  67278. private _barColor;
  67279. private _barHeight;
  67280. private _spacerHeight;
  67281. private _labelColor;
  67282. private _groups;
  67283. private _bars;
  67284. /**
  67285. * Creates a new SelectionPanel
  67286. * @param name of SelectionPanel
  67287. * @param groups is an array of SelectionGroups
  67288. */
  67289. constructor(
  67290. /** name of SelectionPanel */
  67291. name: string,
  67292. /** an array of SelectionGroups */
  67293. groups?: SelectorGroup[]);
  67294. protected _getTypeName(): string;
  67295. /** Gets or sets the headerColor */
  67296. headerColor: string;
  67297. private _setHeaderColor;
  67298. /** Gets or sets the button color */
  67299. buttonColor: string;
  67300. private _setbuttonColor;
  67301. /** Gets or sets the label color */
  67302. labelColor: string;
  67303. private _setLabelColor;
  67304. /** Gets or sets the button background */
  67305. buttonBackground: string;
  67306. private _setButtonBackground;
  67307. /** Gets or sets the color of separator bar */
  67308. barColor: string;
  67309. private _setBarColor;
  67310. /** Gets or sets the height of separator bar */
  67311. barHeight: string;
  67312. private _setBarHeight;
  67313. /** Gets or sets the height of spacers*/
  67314. spacerHeight: string;
  67315. private _setSpacerHeight;
  67316. /** Adds a bar between groups */
  67317. private _addSpacer;
  67318. /** Add a group to the selection panel
  67319. * @param group is the selector group to add
  67320. */
  67321. addGroup(group: SelectorGroup): void;
  67322. /** Remove the group from the given position
  67323. * @param groupNb is the position of the group in the list
  67324. */
  67325. removeGroup(groupNb: number): void;
  67326. /** Change a group header label
  67327. * @param label is the new group header label
  67328. * @param groupNb is the number of the group to relabel
  67329. * */
  67330. setHeaderName(label: string, groupNb: number): void;
  67331. /** Change selector label to the one given
  67332. * @param label is the new selector label
  67333. * @param groupNb is the number of the groupcontaining the selector
  67334. * @param selectorNb is the number of the selector within a group to relabel
  67335. * */
  67336. relabel(label: string, groupNb: number, selectorNb: number): void;
  67337. /** For a given group position remove the selector at the given position
  67338. * @param groupNb is the number of the group to remove the selector from
  67339. * @param selectorNb is the number of the selector within the group
  67340. */
  67341. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67342. /** For a given group position of correct type add a checkbox button
  67343. * @param groupNb is the number of the group to remove the selector from
  67344. * @param label is the label for the selector
  67345. * @param func is the function called when the Selector is checked
  67346. * @param checked is true when Selector is checked
  67347. */
  67348. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67349. /** For a given group position of correct type add a radio button
  67350. * @param groupNb is the number of the group to remove the selector from
  67351. * @param label is the label for the selector
  67352. * @param func is the function called when the Selector is checked
  67353. * @param checked is true when Selector is checked
  67354. */
  67355. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67356. /**
  67357. * For a given slider group add a slider
  67358. * @param groupNb is the number of the group to add the slider to
  67359. * @param label is the label for the Slider
  67360. * @param func is the function called when the Slider moves
  67361. * @param unit is a string describing the units used, eg degrees or metres
  67362. * @param min is the minimum value for the Slider
  67363. * @param max is the maximum value for the Slider
  67364. * @param value is the start value for the Slider between min and max
  67365. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67366. */
  67367. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67368. }
  67369. }
  67370. declare module BABYLON.GUI {
  67371. /**
  67372. * Class used to hold a the container for ScrollViewer
  67373. * @hidden
  67374. */
  67375. export class _ScrollViewerWindow extends Container {
  67376. parentClientWidth: number;
  67377. parentClientHeight: number;
  67378. /**
  67379. * Creates a new ScrollViewerWindow
  67380. * @param name of ScrollViewerWindow
  67381. */
  67382. constructor(name?: string);
  67383. protected _getTypeName(): string;
  67384. /** @hidden */
  67385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67386. protected _postMeasure(): void;
  67387. }
  67388. }
  67389. declare module BABYLON.GUI {
  67390. /**
  67391. * Class used to create slider controls
  67392. */
  67393. export class ScrollBar extends BaseSlider {
  67394. name?: string | undefined;
  67395. private _background;
  67396. private _borderColor;
  67397. private _thumbMeasure;
  67398. /** Gets or sets border color */
  67399. borderColor: string;
  67400. /** Gets or sets background color */
  67401. background: string;
  67402. /**
  67403. * Creates a new Slider
  67404. * @param name defines the control name
  67405. */
  67406. constructor(name?: string | undefined);
  67407. protected _getTypeName(): string;
  67408. protected _getThumbThickness(): number;
  67409. _draw(context: CanvasRenderingContext2D): void;
  67410. private _first;
  67411. private _originX;
  67412. private _originY;
  67413. /** @hidden */
  67414. protected _updateValueFromPointer(x: number, y: number): void;
  67415. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67416. }
  67417. }
  67418. declare module BABYLON.GUI {
  67419. /**
  67420. * Class used to hold a viewer window and sliders in a grid
  67421. */
  67422. export class ScrollViewer extends Rectangle {
  67423. private _grid;
  67424. private _horizontalBarSpace;
  67425. private _verticalBarSpace;
  67426. private _dragSpace;
  67427. private _horizontalBar;
  67428. private _verticalBar;
  67429. private _barColor;
  67430. private _barBackground;
  67431. private _barSize;
  67432. private _endLeft;
  67433. private _endTop;
  67434. private _window;
  67435. private _pointerIsOver;
  67436. private _wheelPrecision;
  67437. private _onPointerObserver;
  67438. private _clientWidth;
  67439. private _clientHeight;
  67440. /**
  67441. * Gets the horizontal scrollbar
  67442. */
  67443. readonly horizontalBar: ScrollBar;
  67444. /**
  67445. * Gets the vertical scrollbar
  67446. */
  67447. readonly verticalBar: ScrollBar;
  67448. /**
  67449. * Adds a new control to the current container
  67450. * @param control defines the control to add
  67451. * @returns the current container
  67452. */
  67453. addControl(control: BABYLON.Nullable<Control>): Container;
  67454. /**
  67455. * Removes a control from the current container
  67456. * @param control defines the control to remove
  67457. * @returns the current container
  67458. */
  67459. removeControl(control: Control): Container;
  67460. /** Gets the list of children */
  67461. readonly children: Control[];
  67462. _flagDescendantsAsMatrixDirty(): void;
  67463. /**
  67464. * Creates a new ScrollViewer
  67465. * @param name of ScrollViewer
  67466. */
  67467. constructor(name?: string);
  67468. /** Reset the scroll viewer window to initial size */
  67469. resetWindow(): void;
  67470. protected _getTypeName(): string;
  67471. private _buildClientSizes;
  67472. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67473. protected _postMeasure(): void;
  67474. /**
  67475. * Gets or sets the mouse wheel precision
  67476. * from 0 to 1 with a default value of 0.05
  67477. * */
  67478. wheelPrecision: number;
  67479. /** Gets or sets the bar color */
  67480. barColor: string;
  67481. /** Gets or sets the size of the bar */
  67482. barSize: number;
  67483. /** Gets or sets the bar background */
  67484. barBackground: string;
  67485. /** @hidden */
  67486. private _updateScroller;
  67487. _link(host: AdvancedDynamicTexture): void;
  67488. /** @hidden */
  67489. private _attachWheel;
  67490. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67491. /** Releases associated resources */
  67492. dispose(): void;
  67493. }
  67494. }
  67495. declare module BABYLON.GUI {
  67496. /** Class used to render a grid */
  67497. export class DisplayGrid extends Control {
  67498. name?: string | undefined;
  67499. private _cellWidth;
  67500. private _cellHeight;
  67501. private _minorLineTickness;
  67502. private _minorLineColor;
  67503. private _majorLineTickness;
  67504. private _majorLineColor;
  67505. private _majorLineFrequency;
  67506. private _background;
  67507. private _displayMajorLines;
  67508. private _displayMinorLines;
  67509. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67510. displayMinorLines: boolean;
  67511. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67512. displayMajorLines: boolean;
  67513. /** Gets or sets background color (Black by default) */
  67514. background: string;
  67515. /** Gets or sets the width of each cell (20 by default) */
  67516. cellWidth: number;
  67517. /** Gets or sets the height of each cell (20 by default) */
  67518. cellHeight: number;
  67519. /** Gets or sets the tickness of minor lines (1 by default) */
  67520. minorLineTickness: number;
  67521. /** Gets or sets the color of minor lines (DarkGray by default) */
  67522. minorLineColor: string;
  67523. /** Gets or sets the tickness of major lines (2 by default) */
  67524. majorLineTickness: number;
  67525. /** Gets or sets the color of major lines (White by default) */
  67526. majorLineColor: string;
  67527. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67528. majorLineFrequency: number;
  67529. /**
  67530. * Creates a new GridDisplayRectangle
  67531. * @param name defines the control name
  67532. */
  67533. constructor(name?: string | undefined);
  67534. _draw(context: CanvasRenderingContext2D): void;
  67535. protected _getTypeName(): string;
  67536. }
  67537. }
  67538. declare module BABYLON.GUI {
  67539. /**
  67540. * Class used to create slider controls based on images
  67541. */
  67542. export class ImageBasedSlider extends BaseSlider {
  67543. name?: string | undefined;
  67544. private _backgroundImage;
  67545. private _thumbImage;
  67546. private _valueBarImage;
  67547. private _tempMeasure;
  67548. displayThumb: boolean;
  67549. /**
  67550. * Gets or sets the image used to render the background
  67551. */
  67552. backgroundImage: Image;
  67553. /**
  67554. * Gets or sets the image used to render the value bar
  67555. */
  67556. valueBarImage: Image;
  67557. /**
  67558. * Gets or sets the image used to render the thumb
  67559. */
  67560. thumbImage: Image;
  67561. /**
  67562. * Creates a new ImageBasedSlider
  67563. * @param name defines the control name
  67564. */
  67565. constructor(name?: string | undefined);
  67566. protected _getTypeName(): string;
  67567. _draw(context: CanvasRenderingContext2D): void;
  67568. }
  67569. }
  67570. declare module BABYLON.GUI {
  67571. /**
  67572. * Forcing an export so that this code will execute
  67573. * @hidden
  67574. */
  67575. const name = "Statics";
  67576. }
  67577. declare module BABYLON.GUI {
  67578. /**
  67579. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67580. */
  67581. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67582. /**
  67583. * Define the instrumented AdvancedDynamicTexture.
  67584. */
  67585. texture: AdvancedDynamicTexture;
  67586. private _captureRenderTime;
  67587. private _renderTime;
  67588. private _captureLayoutTime;
  67589. private _layoutTime;
  67590. private _onBeginRenderObserver;
  67591. private _onEndRenderObserver;
  67592. private _onBeginLayoutObserver;
  67593. private _onEndLayoutObserver;
  67594. /**
  67595. * Gets the perf counter used to capture render time
  67596. */
  67597. readonly renderTimeCounter: BABYLON.PerfCounter;
  67598. /**
  67599. * Gets the perf counter used to capture layout time
  67600. */
  67601. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67602. /**
  67603. * Enable or disable the render time capture
  67604. */
  67605. captureRenderTime: boolean;
  67606. /**
  67607. * Enable or disable the layout time capture
  67608. */
  67609. captureLayoutTime: boolean;
  67610. /**
  67611. * Instantiates a new advanced dynamic texture instrumentation.
  67612. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67613. * @param texture Defines the AdvancedDynamicTexture to instrument
  67614. */
  67615. constructor(
  67616. /**
  67617. * Define the instrumented AdvancedDynamicTexture.
  67618. */
  67619. texture: AdvancedDynamicTexture);
  67620. /**
  67621. * Dispose and release associated resources.
  67622. */
  67623. dispose(): void;
  67624. }
  67625. }
  67626. declare module BABYLON.GUI {
  67627. /**
  67628. * Class used to load GUI via XML.
  67629. */
  67630. export class XmlLoader {
  67631. private _nodes;
  67632. private _nodeTypes;
  67633. private _isLoaded;
  67634. private _objectAttributes;
  67635. private _parentClass;
  67636. /**
  67637. * Create a new xml loader
  67638. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67639. */
  67640. constructor(parentClass?: null);
  67641. private _getChainElement;
  67642. private _getClassAttribute;
  67643. private _createGuiElement;
  67644. private _parseGrid;
  67645. private _parseElement;
  67646. private _prepareSourceElement;
  67647. private _parseElementsFromSource;
  67648. private _parseXml;
  67649. /**
  67650. * Gets if the loading has finished.
  67651. * @returns whether the loading has finished or not
  67652. */
  67653. isLoaded(): boolean;
  67654. /**
  67655. * Gets a loaded node / control by id.
  67656. * @param id the Controls id set in the xml
  67657. * @returns element of type Control
  67658. */
  67659. getNodeById(id: string): any;
  67660. /**
  67661. * Gets all loaded nodes / controls
  67662. * @returns Array of controls
  67663. */
  67664. getNodes(): any;
  67665. /**
  67666. * Initiates the xml layout loading
  67667. * @param xmlFile defines the xml layout to load
  67668. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67669. * @param callback defines the callback called on layout load.
  67670. */
  67671. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67672. }
  67673. }
  67674. declare module BABYLON.GUI {
  67675. /**
  67676. * Class used to create containers for controls
  67677. */
  67678. export class Container3D extends Control3D {
  67679. private _blockLayout;
  67680. /**
  67681. * Gets the list of child controls
  67682. */
  67683. protected _children: Control3D[];
  67684. /**
  67685. * Gets the list of child controls
  67686. */
  67687. readonly children: Array<Control3D>;
  67688. /**
  67689. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67690. * This is helpful to optimize layout operation when adding multiple children in a row
  67691. */
  67692. blockLayout: boolean;
  67693. /**
  67694. * Creates a new container
  67695. * @param name defines the container name
  67696. */
  67697. constructor(name?: string);
  67698. /**
  67699. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67700. * @returns the current container
  67701. */
  67702. updateLayout(): Container3D;
  67703. /**
  67704. * Gets a boolean indicating if the given control is in the children of this control
  67705. * @param control defines the control to check
  67706. * @returns true if the control is in the child list
  67707. */
  67708. containsControl(control: Control3D): boolean;
  67709. /**
  67710. * Adds a control to the children of this control
  67711. * @param control defines the control to add
  67712. * @returns the current container
  67713. */
  67714. addControl(control: Control3D): Container3D;
  67715. /**
  67716. * This function will be called everytime a new control is added
  67717. */
  67718. protected _arrangeChildren(): void;
  67719. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67720. /**
  67721. * Removes a control from the children of this control
  67722. * @param control defines the control to remove
  67723. * @returns the current container
  67724. */
  67725. removeControl(control: Control3D): Container3D;
  67726. protected _getTypeName(): string;
  67727. /**
  67728. * Releases all associated resources
  67729. */
  67730. dispose(): void;
  67731. /** Control rotation will remain unchanged */
  67732. static readonly UNSET_ORIENTATION: number;
  67733. /** Control will rotate to make it look at sphere central axis */
  67734. static readonly FACEORIGIN_ORIENTATION: number;
  67735. /** Control will rotate to make it look back at sphere central axis */
  67736. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67737. /** Control will rotate to look at z axis (0, 0, 1) */
  67738. static readonly FACEFORWARD_ORIENTATION: number;
  67739. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67740. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67741. }
  67742. }
  67743. declare module BABYLON.GUI {
  67744. /**
  67745. * Class used to manage 3D user interface
  67746. * @see http://doc.babylonjs.com/how_to/gui3d
  67747. */
  67748. export class GUI3DManager implements BABYLON.IDisposable {
  67749. private _scene;
  67750. private _sceneDisposeObserver;
  67751. private _utilityLayer;
  67752. private _rootContainer;
  67753. private _pointerObserver;
  67754. private _pointerOutObserver;
  67755. /** @hidden */
  67756. _lastPickedControl: Control3D;
  67757. /** @hidden */
  67758. _lastControlOver: {
  67759. [pointerId: number]: Control3D;
  67760. };
  67761. /** @hidden */
  67762. _lastControlDown: {
  67763. [pointerId: number]: Control3D;
  67764. };
  67765. /**
  67766. * BABYLON.Observable raised when the point picked by the pointer events changed
  67767. */
  67768. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67769. /** @hidden */
  67770. _sharedMaterials: {
  67771. [key: string]: BABYLON.Material;
  67772. };
  67773. /** Gets the hosting scene */
  67774. readonly scene: BABYLON.Scene;
  67775. /** Gets associated utility layer */
  67776. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67777. /**
  67778. * Creates a new GUI3DManager
  67779. * @param scene
  67780. */
  67781. constructor(scene?: BABYLON.Scene);
  67782. private _handlePointerOut;
  67783. private _doPicking;
  67784. /**
  67785. * Gets the root container
  67786. */
  67787. readonly rootContainer: Container3D;
  67788. /**
  67789. * Gets a boolean indicating if the given control is in the root child list
  67790. * @param control defines the control to check
  67791. * @returns true if the control is in the root child list
  67792. */
  67793. containsControl(control: Control3D): boolean;
  67794. /**
  67795. * Adds a control to the root child list
  67796. * @param control defines the control to add
  67797. * @returns the current manager
  67798. */
  67799. addControl(control: Control3D): GUI3DManager;
  67800. /**
  67801. * Removes a control from the root child list
  67802. * @param control defines the control to remove
  67803. * @returns the current container
  67804. */
  67805. removeControl(control: Control3D): GUI3DManager;
  67806. /**
  67807. * Releases all associated resources
  67808. */
  67809. dispose(): void;
  67810. }
  67811. }
  67812. declare module BABYLON.GUI {
  67813. /**
  67814. * Class used to transport BABYLON.Vector3 information for pointer events
  67815. */
  67816. export class Vector3WithInfo extends BABYLON.Vector3 {
  67817. /** defines the current mouse button index */
  67818. buttonIndex: number;
  67819. /**
  67820. * Creates a new Vector3WithInfo
  67821. * @param source defines the vector3 data to transport
  67822. * @param buttonIndex defines the current mouse button index
  67823. */
  67824. constructor(source: BABYLON.Vector3,
  67825. /** defines the current mouse button index */
  67826. buttonIndex?: number);
  67827. }
  67828. }
  67829. declare module BABYLON.GUI {
  67830. /**
  67831. * Class used as base class for controls
  67832. */
  67833. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67834. /** Defines the control name */
  67835. name?: string | undefined;
  67836. /** @hidden */
  67837. _host: GUI3DManager;
  67838. private _node;
  67839. private _downCount;
  67840. private _enterCount;
  67841. private _downPointerIds;
  67842. private _isVisible;
  67843. /** Gets or sets the control position in world space */
  67844. position: BABYLON.Vector3;
  67845. /** Gets or sets the control scaling in world space */
  67846. scaling: BABYLON.Vector3;
  67847. /** Callback used to start pointer enter animation */
  67848. pointerEnterAnimation: () => void;
  67849. /** Callback used to start pointer out animation */
  67850. pointerOutAnimation: () => void;
  67851. /** Callback used to start pointer down animation */
  67852. pointerDownAnimation: () => void;
  67853. /** Callback used to start pointer up animation */
  67854. pointerUpAnimation: () => void;
  67855. /**
  67856. * An event triggered when the pointer move over the control
  67857. */
  67858. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67859. /**
  67860. * An event triggered when the pointer move out of the control
  67861. */
  67862. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67863. /**
  67864. * An event triggered when the pointer taps the control
  67865. */
  67866. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67867. /**
  67868. * An event triggered when pointer is up
  67869. */
  67870. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67871. /**
  67872. * An event triggered when a control is clicked on (with a mouse)
  67873. */
  67874. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67875. /**
  67876. * An event triggered when pointer enters the control
  67877. */
  67878. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67879. /**
  67880. * Gets or sets the parent container
  67881. */
  67882. parent: BABYLON.Nullable<Container3D>;
  67883. private _behaviors;
  67884. /**
  67885. * Gets the list of attached behaviors
  67886. * @see http://doc.babylonjs.com/features/behaviour
  67887. */
  67888. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67889. /**
  67890. * Attach a behavior to the control
  67891. * @see http://doc.babylonjs.com/features/behaviour
  67892. * @param behavior defines the behavior to attach
  67893. * @returns the current control
  67894. */
  67895. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67896. /**
  67897. * Remove an attached behavior
  67898. * @see http://doc.babylonjs.com/features/behaviour
  67899. * @param behavior defines the behavior to attach
  67900. * @returns the current control
  67901. */
  67902. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67903. /**
  67904. * Gets an attached behavior by name
  67905. * @param name defines the name of the behavior to look for
  67906. * @see http://doc.babylonjs.com/features/behaviour
  67907. * @returns null if behavior was not found else the requested behavior
  67908. */
  67909. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67910. /** Gets or sets a boolean indicating if the control is visible */
  67911. isVisible: boolean;
  67912. /**
  67913. * Creates a new control
  67914. * @param name defines the control name
  67915. */
  67916. constructor(
  67917. /** Defines the control name */
  67918. name?: string | undefined);
  67919. /**
  67920. * Gets a string representing the class name
  67921. */
  67922. readonly typeName: string;
  67923. /**
  67924. * Get the current class name of the control.
  67925. * @returns current class name
  67926. */
  67927. getClassName(): string;
  67928. protected _getTypeName(): string;
  67929. /**
  67930. * Gets the transform node used by this control
  67931. */
  67932. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67933. /**
  67934. * Gets the mesh used to render this control
  67935. */
  67936. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67937. /**
  67938. * Link the control as child of the given node
  67939. * @param node defines the node to link to. Use null to unlink the control
  67940. * @returns the current control
  67941. */
  67942. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67943. /** @hidden **/
  67944. _prepareNode(scene: BABYLON.Scene): void;
  67945. /**
  67946. * Node creation.
  67947. * Can be overriden by children
  67948. * @param scene defines the scene where the node must be attached
  67949. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67950. */
  67951. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67952. /**
  67953. * Affect a material to the given mesh
  67954. * @param mesh defines the mesh which will represent the control
  67955. */
  67956. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67957. /** @hidden */
  67958. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67959. /** @hidden */
  67960. _onPointerEnter(target: Control3D): boolean;
  67961. /** @hidden */
  67962. _onPointerOut(target: Control3D): void;
  67963. /** @hidden */
  67964. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67965. /** @hidden */
  67966. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67967. /** @hidden */
  67968. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67969. /** @hidden */
  67970. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67971. /** @hidden */
  67972. _disposeNode(): void;
  67973. /**
  67974. * Releases all associated resources
  67975. */
  67976. dispose(): void;
  67977. }
  67978. }
  67979. declare module BABYLON.GUI {
  67980. /**
  67981. * Class used as a root to all buttons
  67982. */
  67983. export class AbstractButton3D extends Control3D {
  67984. /**
  67985. * Creates a new button
  67986. * @param name defines the control name
  67987. */
  67988. constructor(name?: string);
  67989. protected _getTypeName(): string;
  67990. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67991. }
  67992. }
  67993. declare module BABYLON.GUI {
  67994. /**
  67995. * Class used to create a button in 3D
  67996. */
  67997. export class Button3D extends AbstractButton3D {
  67998. /** @hidden */
  67999. protected _currentMaterial: BABYLON.Material;
  68000. private _facadeTexture;
  68001. private _content;
  68002. private _contentResolution;
  68003. private _contentScaleRatio;
  68004. /**
  68005. * Gets or sets the texture resolution used to render content (512 by default)
  68006. */
  68007. contentResolution: BABYLON.int;
  68008. /**
  68009. * Gets or sets the texture scale ratio used to render content (2 by default)
  68010. */
  68011. contentScaleRatio: number;
  68012. protected _disposeFacadeTexture(): void;
  68013. protected _resetContent(): void;
  68014. /**
  68015. * Creates a new button
  68016. * @param name defines the control name
  68017. */
  68018. constructor(name?: string);
  68019. /**
  68020. * Gets or sets the GUI 2D content used to display the button's facade
  68021. */
  68022. content: Control;
  68023. /**
  68024. * Apply the facade texture (created from the content property).
  68025. * This function can be overloaded by child classes
  68026. * @param facadeTexture defines the AdvancedDynamicTexture to use
  68027. */
  68028. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68029. protected _getTypeName(): string;
  68030. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68031. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68032. /**
  68033. * Releases all associated resources
  68034. */
  68035. dispose(): void;
  68036. }
  68037. }
  68038. declare module BABYLON.GUI {
  68039. /**
  68040. * Abstract class used to create a container panel deployed on the surface of a volume
  68041. */
  68042. export abstract class VolumeBasedPanel extends Container3D {
  68043. private _columns;
  68044. private _rows;
  68045. private _rowThenColum;
  68046. private _orientation;
  68047. protected _cellWidth: number;
  68048. protected _cellHeight: number;
  68049. /**
  68050. * Gets or sets the distance between elements
  68051. */
  68052. margin: number;
  68053. /**
  68054. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  68055. * | Value | Type | Description |
  68056. * | ----- | ----------------------------------- | ----------- |
  68057. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  68058. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  68059. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  68060. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  68061. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  68062. */
  68063. orientation: number;
  68064. /**
  68065. * Gets or sets the number of columns requested (10 by default).
  68066. * The panel will automatically compute the number of rows based on number of child controls.
  68067. */
  68068. columns: BABYLON.int;
  68069. /**
  68070. * Gets or sets a the number of rows requested.
  68071. * The panel will automatically compute the number of columns based on number of child controls.
  68072. */
  68073. rows: BABYLON.int;
  68074. /**
  68075. * Creates new VolumeBasedPanel
  68076. */
  68077. constructor();
  68078. protected _arrangeChildren(): void;
  68079. /** Child classes must implement this function to provide correct control positioning */
  68080. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68081. /** Child classes can implement this function to provide additional processing */
  68082. protected _finalProcessing(): void;
  68083. }
  68084. }
  68085. declare module BABYLON.GUI {
  68086. /**
  68087. * Class used to create a container panel deployed on the surface of a cylinder
  68088. */
  68089. export class CylinderPanel extends VolumeBasedPanel {
  68090. private _radius;
  68091. /**
  68092. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  68093. */
  68094. radius: BABYLON.float;
  68095. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68096. private _cylindricalMapping;
  68097. }
  68098. }
  68099. declare module BABYLON.GUI {
  68100. /** @hidden */
  68101. export var fluentVertexShader: {
  68102. name: string;
  68103. shader: string;
  68104. };
  68105. }
  68106. declare module BABYLON.GUI {
  68107. /** @hidden */
  68108. export var fluentPixelShader: {
  68109. name: string;
  68110. shader: string;
  68111. };
  68112. }
  68113. declare module BABYLON.GUI {
  68114. /** @hidden */
  68115. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  68116. INNERGLOW: boolean;
  68117. BORDER: boolean;
  68118. HOVERLIGHT: boolean;
  68119. TEXTURE: boolean;
  68120. constructor();
  68121. }
  68122. /**
  68123. * Class used to render controls with fluent desgin
  68124. */
  68125. export class FluentMaterial extends BABYLON.PushMaterial {
  68126. /**
  68127. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  68128. */
  68129. innerGlowColorIntensity: number;
  68130. /**
  68131. * Gets or sets the inner glow color (white by default)
  68132. */
  68133. innerGlowColor: BABYLON.Color3;
  68134. /**
  68135. * Gets or sets alpha value (default is 1.0)
  68136. */
  68137. alpha: number;
  68138. /**
  68139. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  68140. */
  68141. albedoColor: BABYLON.Color3;
  68142. /**
  68143. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  68144. */
  68145. renderBorders: boolean;
  68146. /**
  68147. * Gets or sets border width (default is 0.5)
  68148. */
  68149. borderWidth: number;
  68150. /**
  68151. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  68152. */
  68153. edgeSmoothingValue: number;
  68154. /**
  68155. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  68156. */
  68157. borderMinValue: number;
  68158. /**
  68159. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  68160. */
  68161. renderHoverLight: boolean;
  68162. /**
  68163. * Gets or sets the radius used to render the hover light (default is 1.0)
  68164. */
  68165. hoverRadius: number;
  68166. /**
  68167. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  68168. */
  68169. hoverColor: BABYLON.Color4;
  68170. /**
  68171. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  68172. */
  68173. hoverPosition: BABYLON.Vector3;
  68174. private _albedoTexture;
  68175. /** Gets or sets the texture to use for albedo color */
  68176. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68177. /**
  68178. * Creates a new Fluent material
  68179. * @param name defines the name of the material
  68180. * @param scene defines the hosting scene
  68181. */
  68182. constructor(name: string, scene: BABYLON.Scene);
  68183. needAlphaBlending(): boolean;
  68184. needAlphaTesting(): boolean;
  68185. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68186. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68187. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68188. getActiveTextures(): BABYLON.BaseTexture[];
  68189. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68190. dispose(forceDisposeEffect?: boolean): void;
  68191. clone(name: string): FluentMaterial;
  68192. serialize(): any;
  68193. getClassName(): string;
  68194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  68195. }
  68196. }
  68197. declare module BABYLON.GUI {
  68198. /**
  68199. * Class used to create a holographic button in 3D
  68200. */
  68201. export class HolographicButton extends Button3D {
  68202. private _backPlate;
  68203. private _textPlate;
  68204. private _frontPlate;
  68205. private _text;
  68206. private _imageUrl;
  68207. private _shareMaterials;
  68208. private _frontMaterial;
  68209. private _backMaterial;
  68210. private _plateMaterial;
  68211. private _pickedPointObserver;
  68212. private _tooltipFade;
  68213. private _tooltipTextBlock;
  68214. private _tooltipTexture;
  68215. private _tooltipMesh;
  68216. private _tooltipHoverObserver;
  68217. private _tooltipOutObserver;
  68218. private _disposeTooltip;
  68219. /**
  68220. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  68221. */
  68222. tooltipText: BABYLON.Nullable<string>;
  68223. /**
  68224. * Gets or sets text for the button
  68225. */
  68226. text: string;
  68227. /**
  68228. * Gets or sets the image url for the button
  68229. */
  68230. imageUrl: string;
  68231. /**
  68232. * Gets the back material used by this button
  68233. */
  68234. readonly backMaterial: FluentMaterial;
  68235. /**
  68236. * Gets the front material used by this button
  68237. */
  68238. readonly frontMaterial: FluentMaterial;
  68239. /**
  68240. * Gets the plate material used by this button
  68241. */
  68242. readonly plateMaterial: BABYLON.StandardMaterial;
  68243. /**
  68244. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  68245. */
  68246. readonly shareMaterials: boolean;
  68247. /**
  68248. * Creates a new button
  68249. * @param name defines the control name
  68250. */
  68251. constructor(name?: string, shareMaterials?: boolean);
  68252. protected _getTypeName(): string;
  68253. private _rebuildContent;
  68254. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68255. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68256. private _createBackMaterial;
  68257. private _createFrontMaterial;
  68258. private _createPlateMaterial;
  68259. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  68260. /**
  68261. * Releases all associated resources
  68262. */
  68263. dispose(): void;
  68264. }
  68265. }
  68266. declare module BABYLON.GUI {
  68267. /**
  68268. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  68269. */
  68270. export class MeshButton3D extends Button3D {
  68271. /** @hidden */
  68272. protected _currentMesh: BABYLON.Mesh;
  68273. /**
  68274. * Creates a new 3D button based on a mesh
  68275. * @param mesh mesh to become a 3D button
  68276. * @param name defines the control name
  68277. */
  68278. constructor(mesh: BABYLON.Mesh, name?: string);
  68279. protected _getTypeName(): string;
  68280. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68281. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68282. }
  68283. }
  68284. declare module BABYLON.GUI {
  68285. /**
  68286. * Class used to create a container panel deployed on the surface of a plane
  68287. */
  68288. export class PlanePanel extends VolumeBasedPanel {
  68289. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68290. }
  68291. }
  68292. declare module BABYLON.GUI {
  68293. /**
  68294. * Class used to create a container panel where items get randomized planar mapping
  68295. */
  68296. export class ScatterPanel extends VolumeBasedPanel {
  68297. private _iteration;
  68298. /**
  68299. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  68300. */
  68301. iteration: BABYLON.float;
  68302. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68303. private _scatterMapping;
  68304. protected _finalProcessing(): void;
  68305. }
  68306. }
  68307. declare module BABYLON.GUI {
  68308. /**
  68309. * Class used to create a container panel deployed on the surface of a sphere
  68310. */
  68311. export class SpherePanel extends VolumeBasedPanel {
  68312. private _radius;
  68313. /**
  68314. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68315. */
  68316. radius: BABYLON.float;
  68317. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68318. private _sphericalMapping;
  68319. }
  68320. }
  68321. declare module BABYLON.GUI {
  68322. /**
  68323. * Class used to create a stack panel in 3D on XY plane
  68324. */
  68325. export class StackPanel3D extends Container3D {
  68326. private _isVertical;
  68327. /**
  68328. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68329. */
  68330. isVertical: boolean;
  68331. /**
  68332. * Gets or sets the distance between elements
  68333. */
  68334. margin: number;
  68335. /**
  68336. * Creates new StackPanel
  68337. * @param isVertical
  68338. */
  68339. constructor(isVertical?: boolean);
  68340. protected _arrangeChildren(): void;
  68341. }
  68342. }
  68343. declare module BABYLON {
  68344. /**
  68345. * Mode that determines the coordinate system to use.
  68346. */
  68347. export enum GLTFLoaderCoordinateSystemMode {
  68348. /**
  68349. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68350. */
  68351. AUTO = 0,
  68352. /**
  68353. * Sets the useRightHandedSystem flag on the scene.
  68354. */
  68355. FORCE_RIGHT_HANDED = 1
  68356. }
  68357. /**
  68358. * Mode that determines what animations will start.
  68359. */
  68360. export enum GLTFLoaderAnimationStartMode {
  68361. /**
  68362. * No animation will start.
  68363. */
  68364. NONE = 0,
  68365. /**
  68366. * The first animation will start.
  68367. */
  68368. FIRST = 1,
  68369. /**
  68370. * All animations will start.
  68371. */
  68372. ALL = 2
  68373. }
  68374. /**
  68375. * Interface that contains the data for the glTF asset.
  68376. */
  68377. export interface IGLTFLoaderData {
  68378. /**
  68379. * The object that represents the glTF JSON.
  68380. */
  68381. json: Object;
  68382. /**
  68383. * The BIN chunk of a binary glTF.
  68384. */
  68385. bin: Nullable<IDataBuffer>;
  68386. }
  68387. /**
  68388. * Interface for extending the loader.
  68389. */
  68390. export interface IGLTFLoaderExtension {
  68391. /**
  68392. * The name of this extension.
  68393. */
  68394. readonly name: string;
  68395. /**
  68396. * Defines whether this extension is enabled.
  68397. */
  68398. enabled: boolean;
  68399. /**
  68400. * Defines the order of this extension.
  68401. * The loader sorts the extensions using these values when loading.
  68402. */
  68403. order?: number;
  68404. }
  68405. /**
  68406. * Loader state.
  68407. */
  68408. export enum GLTFLoaderState {
  68409. /**
  68410. * The asset is loading.
  68411. */
  68412. LOADING = 0,
  68413. /**
  68414. * The asset is ready for rendering.
  68415. */
  68416. READY = 1,
  68417. /**
  68418. * The asset is completely loaded.
  68419. */
  68420. COMPLETE = 2
  68421. }
  68422. /** @hidden */
  68423. export interface IGLTFLoader extends IDisposable {
  68424. readonly state: Nullable<GLTFLoaderState>;
  68425. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68426. meshes: AbstractMesh[];
  68427. particleSystems: IParticleSystem[];
  68428. skeletons: Skeleton[];
  68429. animationGroups: AnimationGroup[];
  68430. }>;
  68431. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68432. }
  68433. /**
  68434. * File loader for loading glTF files into a scene.
  68435. */
  68436. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68437. /** @hidden */
  68438. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68439. /** @hidden */
  68440. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68441. /**
  68442. * Raised when the asset has been parsed
  68443. */
  68444. onParsedObservable: Observable<IGLTFLoaderData>;
  68445. private _onParsedObserver;
  68446. /**
  68447. * Raised when the asset has been parsed
  68448. */
  68449. onParsed: (loaderData: IGLTFLoaderData) => void;
  68450. /**
  68451. * 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.
  68452. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68453. * Defaults to true.
  68454. * @hidden
  68455. */
  68456. static IncrementalLoading: boolean;
  68457. /**
  68458. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68459. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68460. * @hidden
  68461. */
  68462. static HomogeneousCoordinates: boolean;
  68463. /**
  68464. * The coordinate system mode. Defaults to AUTO.
  68465. */
  68466. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68467. /**
  68468. * The animation start mode. Defaults to FIRST.
  68469. */
  68470. animationStartMode: GLTFLoaderAnimationStartMode;
  68471. /**
  68472. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68473. */
  68474. compileMaterials: boolean;
  68475. /**
  68476. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68477. */
  68478. useClipPlane: boolean;
  68479. /**
  68480. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68481. */
  68482. compileShadowGenerators: boolean;
  68483. /**
  68484. * Defines if the Alpha blended materials are only applied as coverage.
  68485. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68486. * If true, no extra effects are applied to transparent pixels.
  68487. */
  68488. transparencyAsCoverage: boolean;
  68489. /**
  68490. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68491. * Enabling will disable offline support and glTF validator.
  68492. * Defaults to false.
  68493. */
  68494. useRangeRequests: boolean;
  68495. /**
  68496. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68497. */
  68498. createInstances: boolean;
  68499. /**
  68500. * Function called before loading a url referenced by the asset.
  68501. */
  68502. preprocessUrlAsync: (url: string) => Promise<string>;
  68503. /**
  68504. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68505. */
  68506. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68507. private _onMeshLoadedObserver;
  68508. /**
  68509. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68510. */
  68511. onMeshLoaded: (mesh: AbstractMesh) => void;
  68512. /**
  68513. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68514. */
  68515. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68516. private _onTextureLoadedObserver;
  68517. /**
  68518. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68519. */
  68520. onTextureLoaded: (texture: BaseTexture) => void;
  68521. /**
  68522. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68523. */
  68524. readonly onMaterialLoadedObservable: Observable<Material>;
  68525. private _onMaterialLoadedObserver;
  68526. /**
  68527. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68528. */
  68529. onMaterialLoaded: (material: Material) => void;
  68530. /**
  68531. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68532. */
  68533. readonly onCameraLoadedObservable: Observable<Camera>;
  68534. private _onCameraLoadedObserver;
  68535. /**
  68536. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68537. */
  68538. onCameraLoaded: (camera: Camera) => void;
  68539. /**
  68540. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68541. * For assets with LODs, raised when all of the LODs are complete.
  68542. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68543. */
  68544. readonly onCompleteObservable: Observable<void>;
  68545. private _onCompleteObserver;
  68546. /**
  68547. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68548. * For assets with LODs, raised when all of the LODs are complete.
  68549. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68550. */
  68551. onComplete: () => void;
  68552. /**
  68553. * Observable raised when an error occurs.
  68554. */
  68555. readonly onErrorObservable: Observable<any>;
  68556. private _onErrorObserver;
  68557. /**
  68558. * Callback raised when an error occurs.
  68559. */
  68560. onError: (reason: any) => void;
  68561. /**
  68562. * Observable raised after the loader is disposed.
  68563. */
  68564. readonly onDisposeObservable: Observable<void>;
  68565. private _onDisposeObserver;
  68566. /**
  68567. * Callback raised after the loader is disposed.
  68568. */
  68569. onDispose: () => void;
  68570. /**
  68571. * Observable raised after a loader extension is created.
  68572. * Set additional options for a loader extension in this event.
  68573. */
  68574. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68575. private _onExtensionLoadedObserver;
  68576. /**
  68577. * Callback raised after a loader extension is created.
  68578. */
  68579. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68580. /**
  68581. * Defines if the loader logging is enabled.
  68582. */
  68583. loggingEnabled: boolean;
  68584. /**
  68585. * Defines if the loader should capture performance counters.
  68586. */
  68587. capturePerformanceCounters: boolean;
  68588. /**
  68589. * Defines if the loader should validate the asset.
  68590. */
  68591. validate: boolean;
  68592. /**
  68593. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68594. */
  68595. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68596. private _onValidatedObserver;
  68597. /**
  68598. * Callback raised after a loader extension is created.
  68599. */
  68600. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68601. private _loader;
  68602. /**
  68603. * Name of the loader ("gltf")
  68604. */
  68605. name: string;
  68606. /** @hidden */
  68607. extensions: ISceneLoaderPluginExtensions;
  68608. /**
  68609. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68610. */
  68611. dispose(): void;
  68612. /** @hidden */
  68613. _clear(): void;
  68614. /** @hidden */
  68615. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68616. /** @hidden */
  68617. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68618. /** @hidden */
  68619. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68620. meshes: AbstractMesh[];
  68621. particleSystems: IParticleSystem[];
  68622. skeletons: Skeleton[];
  68623. animationGroups: AnimationGroup[];
  68624. }>;
  68625. /** @hidden */
  68626. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68627. /** @hidden */
  68628. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68629. /** @hidden */
  68630. canDirectLoad(data: string): boolean;
  68631. /** @hidden */
  68632. directLoad(scene: Scene, data: string): any;
  68633. /**
  68634. * The callback that allows custom handling of the root url based on the response url.
  68635. * @param rootUrl the original root url
  68636. * @param responseURL the response url if available
  68637. * @returns the new root url
  68638. */
  68639. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68640. /** @hidden */
  68641. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68642. /**
  68643. * The loader state or null if the loader is not active.
  68644. */
  68645. readonly loaderState: Nullable<GLTFLoaderState>;
  68646. /**
  68647. * Returns a promise that resolves when the asset is completely loaded.
  68648. * @returns a promise that resolves when the asset is completely loaded.
  68649. */
  68650. whenCompleteAsync(): Promise<void>;
  68651. private _validateAsync;
  68652. private _getLoader;
  68653. private _parseJson;
  68654. private _unpackBinaryAsync;
  68655. private _unpackBinaryV1Async;
  68656. private _unpackBinaryV2Async;
  68657. private static _parseVersion;
  68658. private static _compareVersion;
  68659. private static readonly _logSpaces;
  68660. private _logIndentLevel;
  68661. private _loggingEnabled;
  68662. /** @hidden */
  68663. _log: (message: string) => void;
  68664. /** @hidden */
  68665. _logOpen(message: string): void;
  68666. /** @hidden */
  68667. _logClose(): void;
  68668. private _logEnabled;
  68669. private _logDisabled;
  68670. private _capturePerformanceCounters;
  68671. /** @hidden */
  68672. _startPerformanceCounter: (counterName: string) => void;
  68673. /** @hidden */
  68674. _endPerformanceCounter: (counterName: string) => void;
  68675. private _startPerformanceCounterEnabled;
  68676. private _startPerformanceCounterDisabled;
  68677. private _endPerformanceCounterEnabled;
  68678. private _endPerformanceCounterDisabled;
  68679. }
  68680. }
  68681. declare module BABYLON.GLTF1 {
  68682. /**
  68683. * Enums
  68684. * @hidden
  68685. */
  68686. export enum EComponentType {
  68687. BYTE = 5120,
  68688. UNSIGNED_BYTE = 5121,
  68689. SHORT = 5122,
  68690. UNSIGNED_SHORT = 5123,
  68691. FLOAT = 5126
  68692. }
  68693. /** @hidden */
  68694. export enum EShaderType {
  68695. FRAGMENT = 35632,
  68696. VERTEX = 35633
  68697. }
  68698. /** @hidden */
  68699. export enum EParameterType {
  68700. BYTE = 5120,
  68701. UNSIGNED_BYTE = 5121,
  68702. SHORT = 5122,
  68703. UNSIGNED_SHORT = 5123,
  68704. INT = 5124,
  68705. UNSIGNED_INT = 5125,
  68706. FLOAT = 5126,
  68707. FLOAT_VEC2 = 35664,
  68708. FLOAT_VEC3 = 35665,
  68709. FLOAT_VEC4 = 35666,
  68710. INT_VEC2 = 35667,
  68711. INT_VEC3 = 35668,
  68712. INT_VEC4 = 35669,
  68713. BOOL = 35670,
  68714. BOOL_VEC2 = 35671,
  68715. BOOL_VEC3 = 35672,
  68716. BOOL_VEC4 = 35673,
  68717. FLOAT_MAT2 = 35674,
  68718. FLOAT_MAT3 = 35675,
  68719. FLOAT_MAT4 = 35676,
  68720. SAMPLER_2D = 35678
  68721. }
  68722. /** @hidden */
  68723. export enum ETextureWrapMode {
  68724. CLAMP_TO_EDGE = 33071,
  68725. MIRRORED_REPEAT = 33648,
  68726. REPEAT = 10497
  68727. }
  68728. /** @hidden */
  68729. export enum ETextureFilterType {
  68730. NEAREST = 9728,
  68731. LINEAR = 9728,
  68732. NEAREST_MIPMAP_NEAREST = 9984,
  68733. LINEAR_MIPMAP_NEAREST = 9985,
  68734. NEAREST_MIPMAP_LINEAR = 9986,
  68735. LINEAR_MIPMAP_LINEAR = 9987
  68736. }
  68737. /** @hidden */
  68738. export enum ETextureFormat {
  68739. ALPHA = 6406,
  68740. RGB = 6407,
  68741. RGBA = 6408,
  68742. LUMINANCE = 6409,
  68743. LUMINANCE_ALPHA = 6410
  68744. }
  68745. /** @hidden */
  68746. export enum ECullingType {
  68747. FRONT = 1028,
  68748. BACK = 1029,
  68749. FRONT_AND_BACK = 1032
  68750. }
  68751. /** @hidden */
  68752. export enum EBlendingFunction {
  68753. ZERO = 0,
  68754. ONE = 1,
  68755. SRC_COLOR = 768,
  68756. ONE_MINUS_SRC_COLOR = 769,
  68757. DST_COLOR = 774,
  68758. ONE_MINUS_DST_COLOR = 775,
  68759. SRC_ALPHA = 770,
  68760. ONE_MINUS_SRC_ALPHA = 771,
  68761. DST_ALPHA = 772,
  68762. ONE_MINUS_DST_ALPHA = 773,
  68763. CONSTANT_COLOR = 32769,
  68764. ONE_MINUS_CONSTANT_COLOR = 32770,
  68765. CONSTANT_ALPHA = 32771,
  68766. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68767. SRC_ALPHA_SATURATE = 776
  68768. }
  68769. /** @hidden */
  68770. export interface IGLTFProperty {
  68771. extensions?: {
  68772. [key: string]: any;
  68773. };
  68774. extras?: Object;
  68775. }
  68776. /** @hidden */
  68777. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68778. name?: string;
  68779. }
  68780. /** @hidden */
  68781. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68782. bufferView: string;
  68783. byteOffset: number;
  68784. byteStride: number;
  68785. count: number;
  68786. type: string;
  68787. componentType: EComponentType;
  68788. max?: number[];
  68789. min?: number[];
  68790. name?: string;
  68791. }
  68792. /** @hidden */
  68793. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68794. buffer: string;
  68795. byteOffset: number;
  68796. byteLength: number;
  68797. byteStride: number;
  68798. target?: number;
  68799. }
  68800. /** @hidden */
  68801. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68802. uri: string;
  68803. byteLength?: number;
  68804. type?: string;
  68805. }
  68806. /** @hidden */
  68807. export interface IGLTFShader extends IGLTFChildRootProperty {
  68808. uri: string;
  68809. type: EShaderType;
  68810. }
  68811. /** @hidden */
  68812. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68813. attributes: string[];
  68814. fragmentShader: string;
  68815. vertexShader: string;
  68816. }
  68817. /** @hidden */
  68818. export interface IGLTFTechniqueParameter {
  68819. type: number;
  68820. count?: number;
  68821. semantic?: string;
  68822. node?: string;
  68823. value?: number | boolean | string | Array<any>;
  68824. source?: string;
  68825. babylonValue?: any;
  68826. }
  68827. /** @hidden */
  68828. export interface IGLTFTechniqueCommonProfile {
  68829. lightingModel: string;
  68830. texcoordBindings: Object;
  68831. parameters?: Array<any>;
  68832. }
  68833. /** @hidden */
  68834. export interface IGLTFTechniqueStatesFunctions {
  68835. blendColor?: number[];
  68836. blendEquationSeparate?: number[];
  68837. blendFuncSeparate?: number[];
  68838. colorMask: boolean[];
  68839. cullFace: number[];
  68840. }
  68841. /** @hidden */
  68842. export interface IGLTFTechniqueStates {
  68843. enable: number[];
  68844. functions: IGLTFTechniqueStatesFunctions;
  68845. }
  68846. /** @hidden */
  68847. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68848. parameters: {
  68849. [key: string]: IGLTFTechniqueParameter;
  68850. };
  68851. program: string;
  68852. attributes: {
  68853. [key: string]: string;
  68854. };
  68855. uniforms: {
  68856. [key: string]: string;
  68857. };
  68858. states: IGLTFTechniqueStates;
  68859. }
  68860. /** @hidden */
  68861. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68862. technique?: string;
  68863. values: string[];
  68864. }
  68865. /** @hidden */
  68866. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68867. attributes: {
  68868. [key: string]: string;
  68869. };
  68870. indices: string;
  68871. material: string;
  68872. mode?: number;
  68873. }
  68874. /** @hidden */
  68875. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68876. primitives: IGLTFMeshPrimitive[];
  68877. }
  68878. /** @hidden */
  68879. export interface IGLTFImage extends IGLTFChildRootProperty {
  68880. uri: string;
  68881. }
  68882. /** @hidden */
  68883. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68884. magFilter?: number;
  68885. minFilter?: number;
  68886. wrapS?: number;
  68887. wrapT?: number;
  68888. }
  68889. /** @hidden */
  68890. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68891. sampler: string;
  68892. source: string;
  68893. format?: ETextureFormat;
  68894. internalFormat?: ETextureFormat;
  68895. target?: number;
  68896. type?: number;
  68897. babylonTexture?: Texture;
  68898. }
  68899. /** @hidden */
  68900. export interface IGLTFAmbienLight {
  68901. color?: number[];
  68902. }
  68903. /** @hidden */
  68904. export interface IGLTFDirectionalLight {
  68905. color?: number[];
  68906. }
  68907. /** @hidden */
  68908. export interface IGLTFPointLight {
  68909. color?: number[];
  68910. constantAttenuation?: number;
  68911. linearAttenuation?: number;
  68912. quadraticAttenuation?: number;
  68913. }
  68914. /** @hidden */
  68915. export interface IGLTFSpotLight {
  68916. color?: number[];
  68917. constantAttenuation?: number;
  68918. fallOfAngle?: number;
  68919. fallOffExponent?: number;
  68920. linearAttenuation?: number;
  68921. quadraticAttenuation?: number;
  68922. }
  68923. /** @hidden */
  68924. export interface IGLTFLight extends IGLTFChildRootProperty {
  68925. type: string;
  68926. }
  68927. /** @hidden */
  68928. export interface IGLTFCameraOrthographic {
  68929. xmag: number;
  68930. ymag: number;
  68931. zfar: number;
  68932. znear: number;
  68933. }
  68934. /** @hidden */
  68935. export interface IGLTFCameraPerspective {
  68936. aspectRatio: number;
  68937. yfov: number;
  68938. zfar: number;
  68939. znear: number;
  68940. }
  68941. /** @hidden */
  68942. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68943. type: string;
  68944. }
  68945. /** @hidden */
  68946. export interface IGLTFAnimationChannelTarget {
  68947. id: string;
  68948. path: string;
  68949. }
  68950. /** @hidden */
  68951. export interface IGLTFAnimationChannel {
  68952. sampler: string;
  68953. target: IGLTFAnimationChannelTarget;
  68954. }
  68955. /** @hidden */
  68956. export interface IGLTFAnimationSampler {
  68957. input: string;
  68958. output: string;
  68959. interpolation?: string;
  68960. }
  68961. /** @hidden */
  68962. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68963. channels?: IGLTFAnimationChannel[];
  68964. parameters?: {
  68965. [key: string]: string;
  68966. };
  68967. samplers?: {
  68968. [key: string]: IGLTFAnimationSampler;
  68969. };
  68970. }
  68971. /** @hidden */
  68972. export interface IGLTFNodeInstanceSkin {
  68973. skeletons: string[];
  68974. skin: string;
  68975. meshes: string[];
  68976. }
  68977. /** @hidden */
  68978. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68979. bindShapeMatrix: number[];
  68980. inverseBindMatrices: string;
  68981. jointNames: string[];
  68982. babylonSkeleton?: Skeleton;
  68983. }
  68984. /** @hidden */
  68985. export interface IGLTFNode extends IGLTFChildRootProperty {
  68986. camera?: string;
  68987. children: string[];
  68988. skin?: string;
  68989. jointName?: string;
  68990. light?: string;
  68991. matrix: number[];
  68992. mesh?: string;
  68993. meshes?: string[];
  68994. rotation?: number[];
  68995. scale?: number[];
  68996. translation?: number[];
  68997. babylonNode?: Node;
  68998. }
  68999. /** @hidden */
  69000. export interface IGLTFScene extends IGLTFChildRootProperty {
  69001. nodes: string[];
  69002. }
  69003. /** @hidden */
  69004. export interface IGLTFRuntime {
  69005. extensions: {
  69006. [key: string]: any;
  69007. };
  69008. accessors: {
  69009. [key: string]: IGLTFAccessor;
  69010. };
  69011. buffers: {
  69012. [key: string]: IGLTFBuffer;
  69013. };
  69014. bufferViews: {
  69015. [key: string]: IGLTFBufferView;
  69016. };
  69017. meshes: {
  69018. [key: string]: IGLTFMesh;
  69019. };
  69020. lights: {
  69021. [key: string]: IGLTFLight;
  69022. };
  69023. cameras: {
  69024. [key: string]: IGLTFCamera;
  69025. };
  69026. nodes: {
  69027. [key: string]: IGLTFNode;
  69028. };
  69029. images: {
  69030. [key: string]: IGLTFImage;
  69031. };
  69032. textures: {
  69033. [key: string]: IGLTFTexture;
  69034. };
  69035. shaders: {
  69036. [key: string]: IGLTFShader;
  69037. };
  69038. programs: {
  69039. [key: string]: IGLTFProgram;
  69040. };
  69041. samplers: {
  69042. [key: string]: IGLTFSampler;
  69043. };
  69044. techniques: {
  69045. [key: string]: IGLTFTechnique;
  69046. };
  69047. materials: {
  69048. [key: string]: IGLTFMaterial;
  69049. };
  69050. animations: {
  69051. [key: string]: IGLTFAnimation;
  69052. };
  69053. skins: {
  69054. [key: string]: IGLTFSkins;
  69055. };
  69056. currentScene?: Object;
  69057. scenes: {
  69058. [key: string]: IGLTFScene;
  69059. };
  69060. extensionsUsed: string[];
  69061. extensionsRequired?: string[];
  69062. buffersCount: number;
  69063. shaderscount: number;
  69064. scene: Scene;
  69065. rootUrl: string;
  69066. loadedBufferCount: number;
  69067. loadedBufferViews: {
  69068. [name: string]: ArrayBufferView;
  69069. };
  69070. loadedShaderCount: number;
  69071. importOnlyMeshes: boolean;
  69072. importMeshesNames?: string[];
  69073. dummyNodes: Node[];
  69074. }
  69075. /** @hidden */
  69076. export interface INodeToRoot {
  69077. bone: Bone;
  69078. node: IGLTFNode;
  69079. id: string;
  69080. }
  69081. /** @hidden */
  69082. export interface IJointNode {
  69083. node: IGLTFNode;
  69084. id: string;
  69085. }
  69086. }
  69087. declare module BABYLON.GLTF1 {
  69088. /**
  69089. * Utils functions for GLTF
  69090. * @hidden
  69091. */
  69092. export class GLTFUtils {
  69093. /**
  69094. * Sets the given "parameter" matrix
  69095. * @param scene: the Scene object
  69096. * @param source: the source node where to pick the matrix
  69097. * @param parameter: the GLTF technique parameter
  69098. * @param uniformName: the name of the shader's uniform
  69099. * @param shaderMaterial: the shader material
  69100. */
  69101. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  69102. /**
  69103. * Sets the given "parameter" matrix
  69104. * @param shaderMaterial: the shader material
  69105. * @param uniform: the name of the shader's uniform
  69106. * @param value: the value of the uniform
  69107. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  69108. */
  69109. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  69110. /**
  69111. * Returns the wrap mode of the texture
  69112. * @param mode: the mode value
  69113. */
  69114. static GetWrapMode(mode: number): number;
  69115. /**
  69116. * Returns the byte stride giving an accessor
  69117. * @param accessor: the GLTF accessor objet
  69118. */
  69119. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  69120. /**
  69121. * Returns the texture filter mode giving a mode value
  69122. * @param mode: the filter mode value
  69123. */
  69124. static GetTextureFilterMode(mode: number): ETextureFilterType;
  69125. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  69126. /**
  69127. * Returns a buffer from its accessor
  69128. * @param gltfRuntime: the GLTF runtime
  69129. * @param accessor: the GLTF accessor
  69130. */
  69131. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  69132. /**
  69133. * Decodes a buffer view into a string
  69134. * @param view: the buffer view
  69135. */
  69136. static DecodeBufferToText(view: ArrayBufferView): string;
  69137. /**
  69138. * Returns the default material of gltf. Related to
  69139. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  69140. * @param scene: the Babylon.js scene
  69141. */
  69142. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  69143. private static _DefaultMaterial;
  69144. }
  69145. }
  69146. declare module BABYLON.GLTF1 {
  69147. /**
  69148. * Implementation of the base glTF spec
  69149. * @hidden
  69150. */
  69151. export class GLTFLoaderBase {
  69152. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  69153. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69154. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  69155. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69156. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  69157. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69158. }
  69159. /**
  69160. * glTF V1 Loader
  69161. * @hidden
  69162. */
  69163. export class GLTFLoader implements IGLTFLoader {
  69164. static Extensions: {
  69165. [name: string]: GLTFLoaderExtension;
  69166. };
  69167. static RegisterExtension(extension: GLTFLoaderExtension): void;
  69168. state: Nullable<GLTFLoaderState>;
  69169. dispose(): void;
  69170. private _importMeshAsync;
  69171. /**
  69172. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  69173. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69174. * @param scene the scene the meshes should be added to
  69175. * @param data gltf data containing information of the meshes in a loaded file
  69176. * @param rootUrl root url to load from
  69177. * @param onProgress event that fires when loading progress has occured
  69178. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69179. */
  69180. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  69181. meshes: AbstractMesh[];
  69182. particleSystems: IParticleSystem[];
  69183. skeletons: Skeleton[];
  69184. animationGroups: AnimationGroup[];
  69185. }>;
  69186. private _loadAsync;
  69187. /**
  69188. * Imports all objects from a loaded gltf file and adds them to the scene
  69189. * @param scene the scene the objects should be added to
  69190. * @param data gltf data containing information of the meshes in a loaded file
  69191. * @param rootUrl root url to load from
  69192. * @param onProgress event that fires when loading progress has occured
  69193. * @returns a promise which completes when objects have been loaded to the scene
  69194. */
  69195. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69196. private _loadShadersAsync;
  69197. private _loadBuffersAsync;
  69198. private _createNodes;
  69199. }
  69200. /** @hidden */
  69201. export abstract class GLTFLoaderExtension {
  69202. private _name;
  69203. constructor(name: string);
  69204. readonly name: string;
  69205. /**
  69206. * Defines an override for loading the runtime
  69207. * Return true to stop further extensions from loading the runtime
  69208. */
  69209. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69210. /**
  69211. * Defines an onverride for creating gltf runtime
  69212. * Return true to stop further extensions from creating the runtime
  69213. */
  69214. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69215. /**
  69216. * Defines an override for loading buffers
  69217. * Return true to stop further extensions from loading this buffer
  69218. */
  69219. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69220. /**
  69221. * Defines an override for loading texture buffers
  69222. * Return true to stop further extensions from loading this texture data
  69223. */
  69224. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69225. /**
  69226. * Defines an override for creating textures
  69227. * Return true to stop further extensions from loading this texture
  69228. */
  69229. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69230. /**
  69231. * Defines an override for loading shader strings
  69232. * Return true to stop further extensions from loading this shader data
  69233. */
  69234. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69235. /**
  69236. * Defines an override for loading materials
  69237. * Return true to stop further extensions from loading this material
  69238. */
  69239. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69240. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69241. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69242. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69243. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69244. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69245. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69246. private static LoadTextureBufferAsync;
  69247. private static CreateTextureAsync;
  69248. private static ApplyExtensions;
  69249. }
  69250. }
  69251. declare module BABYLON.GLTF1 {
  69252. /** @hidden */
  69253. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69254. private _bin;
  69255. constructor();
  69256. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69257. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69258. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69259. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69260. }
  69261. }
  69262. declare module BABYLON.GLTF1 {
  69263. /** @hidden */
  69264. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69265. constructor();
  69266. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69267. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69268. private _loadTexture;
  69269. }
  69270. }
  69271. declare module BABYLON.GLTF2.Loader {
  69272. /**
  69273. * Loader interface with an index field.
  69274. */
  69275. export interface IArrayItem {
  69276. /**
  69277. * The index of this item in the array.
  69278. */
  69279. index: number;
  69280. }
  69281. /**
  69282. * Loader interface with additional members.
  69283. */
  69284. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69285. /** @hidden */
  69286. _data?: Promise<ArrayBufferView>;
  69287. /** @hidden */
  69288. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69289. }
  69290. /**
  69291. * Loader interface with additional members.
  69292. */
  69293. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69294. }
  69295. /** @hidden */
  69296. export interface _IAnimationSamplerData {
  69297. input: Float32Array;
  69298. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69299. output: Float32Array;
  69300. }
  69301. /**
  69302. * Loader interface with additional members.
  69303. */
  69304. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69305. /** @hidden */
  69306. _data?: Promise<_IAnimationSamplerData>;
  69307. }
  69308. /**
  69309. * Loader interface with additional members.
  69310. */
  69311. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69312. channels: IAnimationChannel[];
  69313. samplers: IAnimationSampler[];
  69314. /** @hidden */
  69315. _babylonAnimationGroup?: AnimationGroup;
  69316. }
  69317. /**
  69318. * Loader interface with additional members.
  69319. */
  69320. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69321. /** @hidden */
  69322. _data?: Promise<ArrayBufferView>;
  69323. }
  69324. /**
  69325. * Loader interface with additional members.
  69326. */
  69327. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69328. /** @hidden */
  69329. _data?: Promise<ArrayBufferView>;
  69330. /** @hidden */
  69331. _babylonBuffer?: Promise<Buffer>;
  69332. }
  69333. /**
  69334. * Loader interface with additional members.
  69335. */
  69336. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69337. }
  69338. /**
  69339. * Loader interface with additional members.
  69340. */
  69341. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69342. /** @hidden */
  69343. _data?: Promise<ArrayBufferView>;
  69344. }
  69345. /**
  69346. * Loader interface with additional members.
  69347. */
  69348. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69349. }
  69350. /**
  69351. * Loader interface with additional members.
  69352. */
  69353. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69354. }
  69355. /**
  69356. * Loader interface with additional members.
  69357. */
  69358. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69359. baseColorTexture?: ITextureInfo;
  69360. metallicRoughnessTexture?: ITextureInfo;
  69361. }
  69362. /**
  69363. * Loader interface with additional members.
  69364. */
  69365. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69366. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69367. normalTexture?: IMaterialNormalTextureInfo;
  69368. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69369. emissiveTexture?: ITextureInfo;
  69370. /** @hidden */
  69371. _data?: {
  69372. [babylonDrawMode: number]: {
  69373. babylonMaterial: Material;
  69374. babylonMeshes: AbstractMesh[];
  69375. promise: Promise<void>;
  69376. };
  69377. };
  69378. }
  69379. /**
  69380. * Loader interface with additional members.
  69381. */
  69382. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69383. primitives: IMeshPrimitive[];
  69384. }
  69385. /**
  69386. * Loader interface with additional members.
  69387. */
  69388. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69389. /** @hidden */
  69390. _instanceData?: {
  69391. babylonSourceMesh: Mesh;
  69392. promise: Promise<any>;
  69393. };
  69394. }
  69395. /**
  69396. * Loader interface with additional members.
  69397. */
  69398. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69399. /**
  69400. * The parent glTF node.
  69401. */
  69402. parent?: INode;
  69403. /** @hidden */
  69404. _babylonTransformNode?: TransformNode;
  69405. /** @hidden */
  69406. _primitiveBabylonMeshes?: AbstractMesh[];
  69407. /** @hidden */
  69408. _babylonBones?: Bone[];
  69409. /** @hidden */
  69410. _numMorphTargets?: number;
  69411. }
  69412. /** @hidden */
  69413. export interface _ISamplerData {
  69414. noMipMaps: boolean;
  69415. samplingMode: number;
  69416. wrapU: number;
  69417. wrapV: number;
  69418. }
  69419. /**
  69420. * Loader interface with additional members.
  69421. */
  69422. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69423. /** @hidden */
  69424. _data?: _ISamplerData;
  69425. }
  69426. /**
  69427. * Loader interface with additional members.
  69428. */
  69429. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69430. }
  69431. /**
  69432. * Loader interface with additional members.
  69433. */
  69434. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69435. /** @hidden */
  69436. _data?: {
  69437. babylonSkeleton: Skeleton;
  69438. promise: Promise<void>;
  69439. };
  69440. }
  69441. /**
  69442. * Loader interface with additional members.
  69443. */
  69444. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69445. }
  69446. /**
  69447. * Loader interface with additional members.
  69448. */
  69449. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69450. }
  69451. /**
  69452. * Loader interface with additional members.
  69453. */
  69454. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69455. accessors?: IAccessor[];
  69456. animations?: IAnimation[];
  69457. buffers?: IBuffer[];
  69458. bufferViews?: IBufferView[];
  69459. cameras?: ICamera[];
  69460. images?: IImage[];
  69461. materials?: IMaterial[];
  69462. meshes?: IMesh[];
  69463. nodes?: INode[];
  69464. samplers?: ISampler[];
  69465. scenes?: IScene[];
  69466. skins?: ISkin[];
  69467. textures?: ITexture[];
  69468. }
  69469. }
  69470. declare module BABYLON.GLTF2 {
  69471. /**
  69472. * Interface for a glTF loader extension.
  69473. */
  69474. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69475. /**
  69476. * Called after the loader state changes to LOADING.
  69477. */
  69478. onLoading?(): void;
  69479. /**
  69480. * Called after the loader state changes to READY.
  69481. */
  69482. onReady?(): void;
  69483. /**
  69484. * Define this method to modify the default behavior when loading scenes.
  69485. * @param context The context when loading the asset
  69486. * @param scene The glTF scene property
  69487. * @returns A promise that resolves when the load is complete or null if not handled
  69488. */
  69489. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69490. /**
  69491. * Define this method to modify the default behavior when loading nodes.
  69492. * @param context The context when loading the asset
  69493. * @param node The glTF node property
  69494. * @param assign A function called synchronously after parsing the glTF properties
  69495. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69496. */
  69497. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69498. /**
  69499. * Define this method to modify the default behavior when loading cameras.
  69500. * @param context The context when loading the asset
  69501. * @param camera The glTF camera property
  69502. * @param assign A function called synchronously after parsing the glTF properties
  69503. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69504. */
  69505. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69506. /**
  69507. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69508. * @param context The context when loading the asset
  69509. * @param primitive The glTF mesh primitive property
  69510. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69511. */
  69512. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69513. /**
  69514. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69515. * @param context The context when loading the asset
  69516. * @param name The mesh name when loading the asset
  69517. * @param node The glTF node when loading the asset
  69518. * @param mesh The glTF mesh when loading the asset
  69519. * @param primitive The glTF mesh primitive property
  69520. * @param assign A function called synchronously after parsing the glTF properties
  69521. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69522. */
  69523. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69524. /**
  69525. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69526. * @param context The context when loading the asset
  69527. * @param material The glTF material property
  69528. * @param assign A function called synchronously after parsing the glTF properties
  69529. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69530. */
  69531. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69532. /**
  69533. * Define this method to modify the default behavior when creating materials.
  69534. * @param context The context when loading the asset
  69535. * @param material The glTF material property
  69536. * @param babylonDrawMode The draw mode for the Babylon material
  69537. * @returns The Babylon material or null if not handled
  69538. */
  69539. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69540. /**
  69541. * Define this method to modify the default behavior when loading material properties.
  69542. * @param context The context when loading the asset
  69543. * @param material The glTF material property
  69544. * @param babylonMaterial The Babylon material
  69545. * @returns A promise that resolves when the load is complete or null if not handled
  69546. */
  69547. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69548. /**
  69549. * Define this method to modify the default behavior when loading texture infos.
  69550. * @param context The context when loading the asset
  69551. * @param textureInfo The glTF texture info property
  69552. * @param assign A function called synchronously after parsing the glTF properties
  69553. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69554. */
  69555. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69556. /**
  69557. * Define this method to modify the default behavior when loading animations.
  69558. * @param context The context when loading the asset
  69559. * @param animation The glTF animation property
  69560. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69561. */
  69562. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69563. /**
  69564. * @hidden Define this method to modify the default behavior when loading skins.
  69565. * @param context The context when loading the asset
  69566. * @param node The glTF node property
  69567. * @param skin The glTF skin property
  69568. * @returns A promise that resolves when the load is complete or null if not handled
  69569. */
  69570. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69571. /**
  69572. * @hidden Define this method to modify the default behavior when loading uris.
  69573. * @param context The context when loading the asset
  69574. * @param property The glTF property associated with the uri
  69575. * @param uri The uri to load
  69576. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69577. */
  69578. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69579. /**
  69580. * Define this method to modify the default behavior when loading buffer views.
  69581. * @param context The context when loading the asset
  69582. * @param bufferView The glTF buffer view property
  69583. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69584. */
  69585. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69586. /**
  69587. * Define this method to modify the default behavior when loading buffers.
  69588. * @param context The context when loading the asset
  69589. * @param buffer The glTF buffer property
  69590. * @param byteOffset The byte offset to load
  69591. * @param byteLength The byte length to load
  69592. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69593. */
  69594. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69595. }
  69596. }
  69597. declare module BABYLON.GLTF2 {
  69598. /**
  69599. * Helper class for working with arrays when loading the glTF asset
  69600. */
  69601. export class ArrayItem {
  69602. /**
  69603. * Gets an item from the given array.
  69604. * @param context The context when loading the asset
  69605. * @param array The array to get the item from
  69606. * @param index The index to the array
  69607. * @returns The array item
  69608. */
  69609. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69610. /**
  69611. * Assign an `index` field to each item of the given array.
  69612. * @param array The array of items
  69613. */
  69614. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69615. }
  69616. /**
  69617. * The glTF 2.0 loader
  69618. */
  69619. export class GLTFLoader implements IGLTFLoader {
  69620. /** @hidden */
  69621. _completePromises: Promise<any>[];
  69622. private _disposed;
  69623. private _parent;
  69624. private _state;
  69625. private _extensions;
  69626. private _rootUrl;
  69627. private _fileName;
  69628. private _uniqueRootUrl;
  69629. private _gltf;
  69630. private _bin;
  69631. private _babylonScene;
  69632. private _rootBabylonMesh;
  69633. private _defaultBabylonMaterialData;
  69634. private _progressCallback?;
  69635. private _requests;
  69636. private static readonly _DefaultSampler;
  69637. private static _RegisteredExtensions;
  69638. /**
  69639. * Registers a loader extension.
  69640. * @param name The name of the loader extension.
  69641. * @param factory The factory function that creates the loader extension.
  69642. */
  69643. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69644. /**
  69645. * Unregisters a loader extension.
  69646. * @param name The name of the loader extension.
  69647. * @returns A boolean indicating whether the extension has been unregistered
  69648. */
  69649. static UnregisterExtension(name: string): boolean;
  69650. /**
  69651. * Gets the loader state.
  69652. */
  69653. readonly state: Nullable<GLTFLoaderState>;
  69654. /**
  69655. * The object that represents the glTF JSON.
  69656. */
  69657. readonly gltf: IGLTF;
  69658. /**
  69659. * The BIN chunk of a binary glTF.
  69660. */
  69661. readonly bin: Nullable<IDataBuffer>;
  69662. /**
  69663. * The parent file loader.
  69664. */
  69665. readonly parent: GLTFFileLoader;
  69666. /**
  69667. * The Babylon scene when loading the asset.
  69668. */
  69669. readonly babylonScene: Scene;
  69670. /**
  69671. * The root Babylon mesh when loading the asset.
  69672. */
  69673. readonly rootBabylonMesh: Mesh;
  69674. /** @hidden */
  69675. constructor(parent: GLTFFileLoader);
  69676. /** @hidden */
  69677. dispose(): void;
  69678. /** @hidden */
  69679. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69680. meshes: AbstractMesh[];
  69681. particleSystems: IParticleSystem[];
  69682. skeletons: Skeleton[];
  69683. animationGroups: AnimationGroup[];
  69684. }>;
  69685. /** @hidden */
  69686. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69687. private _loadAsync;
  69688. private _loadData;
  69689. private _setupData;
  69690. private _loadExtensions;
  69691. private _checkExtensions;
  69692. private _setState;
  69693. private _createRootNode;
  69694. /**
  69695. * Loads a glTF scene.
  69696. * @param context The context when loading the asset
  69697. * @param scene The glTF scene property
  69698. * @returns A promise that resolves when the load is complete
  69699. */
  69700. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69701. private _forEachPrimitive;
  69702. private _getMeshes;
  69703. private _getSkeletons;
  69704. private _getAnimationGroups;
  69705. private _startAnimations;
  69706. /**
  69707. * Loads a glTF node.
  69708. * @param context The context when loading the asset
  69709. * @param node The glTF node property
  69710. * @param assign A function called synchronously after parsing the glTF properties
  69711. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69712. */
  69713. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69714. private _loadMeshAsync;
  69715. /**
  69716. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69717. * @param context The context when loading the asset
  69718. * @param name The mesh name when loading the asset
  69719. * @param node The glTF node when loading the asset
  69720. * @param mesh The glTF mesh when loading the asset
  69721. * @param primitive The glTF mesh primitive property
  69722. * @param assign A function called synchronously after parsing the glTF properties
  69723. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69724. */
  69725. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69726. private _loadVertexDataAsync;
  69727. private _createMorphTargets;
  69728. private _loadMorphTargetsAsync;
  69729. private _loadMorphTargetVertexDataAsync;
  69730. private static _LoadTransform;
  69731. private _loadSkinAsync;
  69732. private _loadBones;
  69733. private _loadBone;
  69734. private _loadSkinInverseBindMatricesDataAsync;
  69735. private _updateBoneMatrices;
  69736. private _getNodeMatrix;
  69737. /**
  69738. * Loads a glTF camera.
  69739. * @param context The context when loading the asset
  69740. * @param camera The glTF camera property
  69741. * @param assign A function called synchronously after parsing the glTF properties
  69742. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69743. */
  69744. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69745. private _loadAnimationsAsync;
  69746. /**
  69747. * Loads a glTF animation.
  69748. * @param context The context when loading the asset
  69749. * @param animation The glTF animation property
  69750. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69751. */
  69752. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69753. /**
  69754. * @hidden Loads a glTF animation channel.
  69755. * @param context The context when loading the asset
  69756. * @param animationContext The context of the animation when loading the asset
  69757. * @param animation The glTF animation property
  69758. * @param channel The glTF animation channel property
  69759. * @param babylonAnimationGroup The babylon animation group property
  69760. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69761. * @returns A void promise when the channel load is complete
  69762. */
  69763. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69764. private _loadAnimationSamplerAsync;
  69765. private _loadBufferAsync;
  69766. /**
  69767. * Loads a glTF buffer view.
  69768. * @param context The context when loading the asset
  69769. * @param bufferView The glTF buffer view property
  69770. * @returns A promise that resolves with the loaded data when the load is complete
  69771. */
  69772. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69773. private _loadAccessorAsync;
  69774. private _loadFloatAccessorAsync;
  69775. private _loadIndicesAccessorAsync;
  69776. private _loadVertexBufferViewAsync;
  69777. private _loadVertexAccessorAsync;
  69778. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69779. /** @hidden */
  69780. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69781. private _createDefaultMaterial;
  69782. /**
  69783. * Creates a Babylon material from a glTF material.
  69784. * @param context The context when loading the asset
  69785. * @param material The glTF material property
  69786. * @param babylonDrawMode The draw mode for the Babylon material
  69787. * @returns The Babylon material
  69788. */
  69789. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69790. /**
  69791. * Loads properties from a glTF material into a Babylon material.
  69792. * @param context The context when loading the asset
  69793. * @param material The glTF material property
  69794. * @param babylonMaterial The Babylon material
  69795. * @returns A promise that resolves when the load is complete
  69796. */
  69797. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69798. /**
  69799. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69800. * @param context The context when loading the asset
  69801. * @param material The glTF material property
  69802. * @param babylonMaterial The Babylon material
  69803. * @returns A promise that resolves when the load is complete
  69804. */
  69805. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69806. /**
  69807. * Loads the alpha properties from a glTF material into a Babylon material.
  69808. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69809. * @param context The context when loading the asset
  69810. * @param material The glTF material property
  69811. * @param babylonMaterial The Babylon material
  69812. */
  69813. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69814. /**
  69815. * Loads a glTF texture info.
  69816. * @param context The context when loading the asset
  69817. * @param textureInfo The glTF texture info property
  69818. * @param assign A function called synchronously after parsing the glTF properties
  69819. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69820. */
  69821. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69822. private _loadTextureAsync;
  69823. private _loadSampler;
  69824. /**
  69825. * Loads a glTF image.
  69826. * @param context The context when loading the asset
  69827. * @param image The glTF image property
  69828. * @returns A promise that resolves with the loaded data when the load is complete
  69829. */
  69830. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69831. /**
  69832. * Loads a glTF uri.
  69833. * @param context The context when loading the asset
  69834. * @param property The glTF property associated with the uri
  69835. * @param uri The base64 or relative uri
  69836. * @returns A promise that resolves with the loaded data when the load is complete
  69837. */
  69838. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69839. private _onProgress;
  69840. /**
  69841. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69842. * @param babylonObject the Babylon object with metadata
  69843. * @param pointer the JSON pointer
  69844. */
  69845. static AddPointerMetadata(babylonObject: {
  69846. metadata: any;
  69847. }, pointer: string): void;
  69848. private static _GetTextureWrapMode;
  69849. private static _GetTextureSamplingMode;
  69850. private static _GetTypedArrayConstructor;
  69851. private static _GetTypedArray;
  69852. private static _GetNumComponents;
  69853. private static _ValidateUri;
  69854. private static _GetDrawMode;
  69855. private _compileMaterialsAsync;
  69856. private _compileShadowGeneratorsAsync;
  69857. private _forEachExtensions;
  69858. private _applyExtensions;
  69859. private _extensionsOnLoading;
  69860. private _extensionsOnReady;
  69861. private _extensionsLoadSceneAsync;
  69862. private _extensionsLoadNodeAsync;
  69863. private _extensionsLoadCameraAsync;
  69864. private _extensionsLoadVertexDataAsync;
  69865. private _extensionsLoadMeshPrimitiveAsync;
  69866. private _extensionsLoadMaterialAsync;
  69867. private _extensionsCreateMaterial;
  69868. private _extensionsLoadMaterialPropertiesAsync;
  69869. private _extensionsLoadTextureInfoAsync;
  69870. private _extensionsLoadAnimationAsync;
  69871. private _extensionsLoadSkinAsync;
  69872. private _extensionsLoadUriAsync;
  69873. private _extensionsLoadBufferViewAsync;
  69874. private _extensionsLoadBufferAsync;
  69875. /**
  69876. * Helper method called by a loader extension to load an glTF extension.
  69877. * @param context The context when loading the asset
  69878. * @param property The glTF property to load the extension from
  69879. * @param extensionName The name of the extension to load
  69880. * @param actionAsync The action to run
  69881. * @returns The promise returned by actionAsync or null if the extension does not exist
  69882. */
  69883. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69884. /**
  69885. * Helper method called by a loader extension to load a glTF extra.
  69886. * @param context The context when loading the asset
  69887. * @param property The glTF property to load the extra from
  69888. * @param extensionName The name of the extension to load
  69889. * @param actionAsync The action to run
  69890. * @returns The promise returned by actionAsync or null if the extra does not exist
  69891. */
  69892. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69893. /**
  69894. * Checks for presence of an extension.
  69895. * @param name The name of the extension to check
  69896. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  69897. */
  69898. isExtensionUsed(name: string): boolean;
  69899. /**
  69900. * Increments the indentation level and logs a message.
  69901. * @param message The message to log
  69902. */
  69903. logOpen(message: string): void;
  69904. /**
  69905. * Decrements the indentation level.
  69906. */
  69907. logClose(): void;
  69908. /**
  69909. * Logs a message
  69910. * @param message The message to log
  69911. */
  69912. log(message: string): void;
  69913. /**
  69914. * Starts a performance counter.
  69915. * @param counterName The name of the performance counter
  69916. */
  69917. startPerformanceCounter(counterName: string): void;
  69918. /**
  69919. * Ends a performance counter.
  69920. * @param counterName The name of the performance counter
  69921. */
  69922. endPerformanceCounter(counterName: string): void;
  69923. }
  69924. }
  69925. declare module BABYLON.GLTF2.Loader.Extensions {
  69926. /**
  69927. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  69928. */
  69929. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69930. /**
  69931. * The name of this extension.
  69932. */
  69933. readonly name: string;
  69934. /**
  69935. * Defines whether this extension is enabled.
  69936. */
  69937. enabled: boolean;
  69938. private _loader;
  69939. private _lights?;
  69940. /** @hidden */
  69941. constructor(loader: GLTFLoader);
  69942. /** @hidden */
  69943. dispose(): void;
  69944. /** @hidden */
  69945. onLoading(): void;
  69946. /** @hidden */
  69947. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69948. private _loadLightAsync;
  69949. }
  69950. }
  69951. declare module BABYLON.GLTF2.Loader.Extensions {
  69952. /**
  69953. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69954. */
  69955. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69956. /**
  69957. * The name of this extension.
  69958. */
  69959. readonly name: string;
  69960. /**
  69961. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  69962. */
  69963. dracoCompression?: DracoCompression;
  69964. /**
  69965. * Defines whether this extension is enabled.
  69966. */
  69967. enabled: boolean;
  69968. private _loader;
  69969. /** @hidden */
  69970. constructor(loader: GLTFLoader);
  69971. /** @hidden */
  69972. dispose(): void;
  69973. /** @hidden */
  69974. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69975. }
  69976. }
  69977. declare module BABYLON.GLTF2.Loader.Extensions {
  69978. /**
  69979. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69980. */
  69981. export class KHR_lights implements IGLTFLoaderExtension {
  69982. /**
  69983. * The name of this extension.
  69984. */
  69985. readonly name: string;
  69986. /**
  69987. * Defines whether this extension is enabled.
  69988. */
  69989. enabled: boolean;
  69990. private _loader;
  69991. private _lights?;
  69992. /** @hidden */
  69993. constructor(loader: GLTFLoader);
  69994. /** @hidden */
  69995. dispose(): void;
  69996. /** @hidden */
  69997. onLoading(): void;
  69998. /** @hidden */
  69999. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70000. }
  70001. }
  70002. declare module BABYLON.GLTF2.Loader.Extensions {
  70003. /**
  70004. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  70005. */
  70006. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  70007. /**
  70008. * The name of this extension.
  70009. */
  70010. readonly name: string;
  70011. /**
  70012. * Defines whether this extension is enabled.
  70013. */
  70014. enabled: boolean;
  70015. /**
  70016. * Defines a number that determines the order the extensions are applied.
  70017. */
  70018. order: number;
  70019. private _loader;
  70020. /** @hidden */
  70021. constructor(loader: GLTFLoader);
  70022. /** @hidden */
  70023. dispose(): void;
  70024. /** @hidden */
  70025. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70026. private _loadSpecularGlossinessPropertiesAsync;
  70027. }
  70028. }
  70029. declare module BABYLON.GLTF2.Loader.Extensions {
  70030. /**
  70031. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  70032. */
  70033. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  70034. /**
  70035. * The name of this extension.
  70036. */
  70037. readonly name: string;
  70038. /**
  70039. * Defines whether this extension is enabled.
  70040. */
  70041. enabled: boolean;
  70042. /**
  70043. * Defines a number that determines the order the extensions are applied.
  70044. */
  70045. order: number;
  70046. private _loader;
  70047. /** @hidden */
  70048. constructor(loader: GLTFLoader);
  70049. /** @hidden */
  70050. dispose(): void;
  70051. /** @hidden */
  70052. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70053. private _loadUnlitPropertiesAsync;
  70054. }
  70055. }
  70056. declare module BABYLON.GLTF2.Loader.Extensions {
  70057. /**
  70058. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70059. * [Playground Sample](https://www.babylonjs-playground.com/#7F7PN6)
  70060. * !!! Experimental Extension Subject to Changes !!!
  70061. */
  70062. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  70063. /**
  70064. * The name of this extension.
  70065. */
  70066. readonly name: string;
  70067. /**
  70068. * Defines whether this extension is enabled.
  70069. */
  70070. enabled: boolean;
  70071. /**
  70072. * Defines a number that determines the order the extensions are applied.
  70073. */
  70074. order: number;
  70075. private _loader;
  70076. /** @hidden */
  70077. constructor(loader: GLTFLoader);
  70078. /** @hidden */
  70079. dispose(): void;
  70080. /** @hidden */
  70081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70082. private _loadClearCoatPropertiesAsync;
  70083. }
  70084. }
  70085. declare module BABYLON.GLTF2.Loader.Extensions {
  70086. /**
  70087. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  70088. * !!! Experimental Extension Subject to Changes !!!
  70089. */
  70090. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  70091. /**
  70092. * The name of this extension.
  70093. */
  70094. readonly name: string;
  70095. /**
  70096. * Defines whether this extension is enabled.
  70097. */
  70098. enabled: boolean;
  70099. /**
  70100. * Defines a number that determines the order the extensions are applied.
  70101. */
  70102. order: number;
  70103. private _loader;
  70104. /** @hidden */
  70105. constructor(loader: GLTFLoader);
  70106. /** @hidden */
  70107. dispose(): void;
  70108. /** @hidden */
  70109. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70110. private _loadSheenPropertiesAsync;
  70111. }
  70112. }
  70113. declare module BABYLON.GLTF2.Loader.Extensions {
  70114. /**
  70115. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70116. * !!! Experimental Extension Subject to Changes !!!
  70117. */
  70118. export class KHR_materials_specular implements IGLTFLoaderExtension {
  70119. /**
  70120. * The name of this extension.
  70121. */
  70122. readonly name: string;
  70123. /**
  70124. * Defines whether this extension is enabled.
  70125. */
  70126. enabled: boolean;
  70127. /**
  70128. * Defines a number that determines the order the extensions are applied.
  70129. */
  70130. order: number;
  70131. private _loader;
  70132. /** @hidden */
  70133. constructor(loader: GLTFLoader);
  70134. /** @hidden */
  70135. dispose(): void;
  70136. /** @hidden */
  70137. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70138. private _loadSpecularPropertiesAsync;
  70139. }
  70140. }
  70141. declare module BABYLON.GLTF2.Loader.Extensions {
  70142. /**
  70143. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  70144. */
  70145. export class KHR_texture_transform implements IGLTFLoaderExtension {
  70146. /**
  70147. * The name of this extension.
  70148. */
  70149. readonly name: string;
  70150. /**
  70151. * Defines whether this extension is enabled.
  70152. */
  70153. enabled: boolean;
  70154. private _loader;
  70155. /** @hidden */
  70156. constructor(loader: GLTFLoader);
  70157. /** @hidden */
  70158. dispose(): void;
  70159. /** @hidden */
  70160. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70161. }
  70162. }
  70163. declare module BABYLON.GLTF2.Loader.Extensions {
  70164. /**
  70165. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  70166. */
  70167. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  70168. /**
  70169. * The name of this extension.
  70170. */
  70171. readonly name: string;
  70172. /**
  70173. * Defines whether this extension is enabled.
  70174. */
  70175. enabled: boolean;
  70176. private _loader;
  70177. private _clips;
  70178. private _emitters;
  70179. /** @hidden */
  70180. constructor(loader: GLTFLoader);
  70181. /** @hidden */
  70182. dispose(): void;
  70183. /** @hidden */
  70184. onLoading(): void;
  70185. /** @hidden */
  70186. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70187. /** @hidden */
  70188. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70189. /** @hidden */
  70190. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70191. private _loadClipAsync;
  70192. private _loadEmitterAsync;
  70193. private _getEventAction;
  70194. private _loadAnimationEventAsync;
  70195. }
  70196. }
  70197. declare module BABYLON.GLTF2.Loader.Extensions {
  70198. /**
  70199. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  70200. */
  70201. export class MSFT_lod implements IGLTFLoaderExtension {
  70202. /**
  70203. * The name of this extension.
  70204. */
  70205. readonly name: string;
  70206. /**
  70207. * Defines whether this extension is enabled.
  70208. */
  70209. enabled: boolean;
  70210. /**
  70211. * Defines a number that determines the order the extensions are applied.
  70212. */
  70213. order: number;
  70214. /**
  70215. * Maximum number of LODs to load, starting from the lowest LOD.
  70216. */
  70217. maxLODsToLoad: number;
  70218. /**
  70219. * Observable raised when all node LODs of one level are loaded.
  70220. * The event data is the index of the loaded LOD starting from zero.
  70221. * Dispose the loader to cancel the loading of the next level of LODs.
  70222. */
  70223. onNodeLODsLoadedObservable: Observable<number>;
  70224. /**
  70225. * Observable raised when all material LODs of one level are loaded.
  70226. * The event data is the index of the loaded LOD starting from zero.
  70227. * Dispose the loader to cancel the loading of the next level of LODs.
  70228. */
  70229. onMaterialLODsLoadedObservable: Observable<number>;
  70230. private _loader;
  70231. private _nodeIndexLOD;
  70232. private _nodeSignalLODs;
  70233. private _nodePromiseLODs;
  70234. private _materialIndexLOD;
  70235. private _materialSignalLODs;
  70236. private _materialPromiseLODs;
  70237. private _indexLOD;
  70238. private _bufferLODs;
  70239. /** @hidden */
  70240. constructor(loader: GLTFLoader);
  70241. /** @hidden */
  70242. dispose(): void;
  70243. /** @hidden */
  70244. onReady(): void;
  70245. /** @hidden */
  70246. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70247. /** @hidden */
  70248. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70249. /** @hidden */
  70250. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70251. /** @hidden */
  70252. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70253. private _loadBufferLOD;
  70254. /**
  70255. * Gets an array of LOD properties from lowest to highest.
  70256. */
  70257. private _getLODs;
  70258. private _disposeUnusedMaterials;
  70259. }
  70260. }
  70261. declare module BABYLON.GLTF2.Loader.Extensions {
  70262. /** @hidden */
  70263. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  70264. readonly name: string;
  70265. enabled: boolean;
  70266. private _loader;
  70267. constructor(loader: GLTFLoader);
  70268. dispose(): void;
  70269. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70270. }
  70271. }
  70272. declare module BABYLON.GLTF2.Loader.Extensions {
  70273. /** @hidden */
  70274. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  70275. readonly name: string;
  70276. enabled: boolean;
  70277. private _loader;
  70278. constructor(loader: GLTFLoader);
  70279. dispose(): void;
  70280. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70281. }
  70282. }
  70283. declare module BABYLON.GLTF2.Loader.Extensions {
  70284. /**
  70285. * Store glTF extras (if present) in BJS objects' metadata
  70286. */
  70287. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  70288. /**
  70289. * The name of this extension.
  70290. */
  70291. readonly name: string;
  70292. /**
  70293. * Defines whether this extension is enabled.
  70294. */
  70295. enabled: boolean;
  70296. private _loader;
  70297. private _assignExtras;
  70298. /** @hidden */
  70299. constructor(loader: GLTFLoader);
  70300. /** @hidden */
  70301. dispose(): void;
  70302. /** @hidden */
  70303. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70304. /** @hidden */
  70305. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70306. /** @hidden */
  70307. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70308. }
  70309. }
  70310. declare module BABYLON {
  70311. /**
  70312. * Class reading and parsing the MTL file bundled with the obj file.
  70313. */
  70314. export class MTLFileLoader {
  70315. /**
  70316. * All material loaded from the mtl will be set here
  70317. */
  70318. materials: StandardMaterial[];
  70319. /**
  70320. * This function will read the mtl file and create each material described inside
  70321. * This function could be improve by adding :
  70322. * -some component missing (Ni, Tf...)
  70323. * -including the specific options available
  70324. *
  70325. * @param scene defines the scene the material will be created in
  70326. * @param data defines the mtl data to parse
  70327. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70328. */
  70329. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70330. /**
  70331. * Gets the texture for the material.
  70332. *
  70333. * If the material is imported from input file,
  70334. * We sanitize the url to ensure it takes the textre from aside the material.
  70335. *
  70336. * @param rootUrl The root url to load from
  70337. * @param value The value stored in the mtl
  70338. * @return The Texture
  70339. */
  70340. private static _getTexture;
  70341. }
  70342. /**
  70343. * Options for loading OBJ/MTL files
  70344. */
  70345. type MeshLoadOptions = {
  70346. /**
  70347. * Defines if UVs are optimized by default during load.
  70348. */
  70349. OptimizeWithUV: boolean;
  70350. /**
  70351. * Defines custom scaling of UV coordinates of loaded meshes.
  70352. */
  70353. UVScaling: Vector2;
  70354. /**
  70355. * Invert model on y-axis (does a model scaling inversion)
  70356. */
  70357. InvertY: boolean;
  70358. /**
  70359. * Invert Y-Axis of referenced textures on load
  70360. */
  70361. InvertTextureY: boolean;
  70362. /**
  70363. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70364. */
  70365. ImportVertexColors: boolean;
  70366. /**
  70367. * Compute the normals for the model, even if normals are present in the file.
  70368. */
  70369. ComputeNormals: boolean;
  70370. /**
  70371. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70372. */
  70373. SkipMaterials: boolean;
  70374. /**
  70375. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70376. */
  70377. MaterialLoadingFailsSilently: boolean;
  70378. };
  70379. /**
  70380. * OBJ file type loader.
  70381. * This is a babylon scene loader plugin.
  70382. */
  70383. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70384. /**
  70385. * Defines if UVs are optimized by default during load.
  70386. */
  70387. static OPTIMIZE_WITH_UV: boolean;
  70388. /**
  70389. * Invert model on y-axis (does a model scaling inversion)
  70390. */
  70391. static INVERT_Y: boolean;
  70392. /**
  70393. * Invert Y-Axis of referenced textures on load
  70394. */
  70395. static INVERT_TEXTURE_Y: boolean;
  70396. /**
  70397. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70398. */
  70399. static IMPORT_VERTEX_COLORS: boolean;
  70400. /**
  70401. * Compute the normals for the model, even if normals are present in the file.
  70402. */
  70403. static COMPUTE_NORMALS: boolean;
  70404. /**
  70405. * Defines custom scaling of UV coordinates of loaded meshes.
  70406. */
  70407. static UV_SCALING: Vector2;
  70408. /**
  70409. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70410. */
  70411. static SKIP_MATERIALS: boolean;
  70412. /**
  70413. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70414. *
  70415. * Defaults to true for backwards compatibility.
  70416. */
  70417. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70418. /**
  70419. * Defines the name of the plugin.
  70420. */
  70421. name: string;
  70422. /**
  70423. * Defines the extension the plugin is able to load.
  70424. */
  70425. extensions: string;
  70426. /** @hidden */
  70427. obj: RegExp;
  70428. /** @hidden */
  70429. group: RegExp;
  70430. /** @hidden */
  70431. mtllib: RegExp;
  70432. /** @hidden */
  70433. usemtl: RegExp;
  70434. /** @hidden */
  70435. smooth: RegExp;
  70436. /** @hidden */
  70437. vertexPattern: RegExp;
  70438. /** @hidden */
  70439. normalPattern: RegExp;
  70440. /** @hidden */
  70441. uvPattern: RegExp;
  70442. /** @hidden */
  70443. facePattern1: RegExp;
  70444. /** @hidden */
  70445. facePattern2: RegExp;
  70446. /** @hidden */
  70447. facePattern3: RegExp;
  70448. /** @hidden */
  70449. facePattern4: RegExp;
  70450. /** @hidden */
  70451. facePattern5: RegExp;
  70452. private _meshLoadOptions;
  70453. /**
  70454. * Creates loader for .OBJ files
  70455. *
  70456. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70457. */
  70458. constructor(meshLoadOptions?: MeshLoadOptions);
  70459. private static readonly currentMeshLoadOptions;
  70460. /**
  70461. * Calls synchronously the MTL file attached to this obj.
  70462. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70463. * Without this function materials are not displayed in the first frame (but displayed after).
  70464. * In consequence it is impossible to get material information in your HTML file
  70465. *
  70466. * @param url The URL of the MTL file
  70467. * @param rootUrl
  70468. * @param onSuccess Callback function to be called when the MTL file is loaded
  70469. * @private
  70470. */
  70471. private _loadMTL;
  70472. /**
  70473. * Instantiates a OBJ file loader plugin.
  70474. * @returns the created plugin
  70475. */
  70476. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70477. /**
  70478. * If the data string can be loaded directly.
  70479. *
  70480. * @param data string containing the file data
  70481. * @returns if the data can be loaded directly
  70482. */
  70483. canDirectLoad(data: string): boolean;
  70484. /**
  70485. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70486. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70487. * @param scene the scene the meshes should be added to
  70488. * @param data the OBJ data to load
  70489. * @param rootUrl root url to load from
  70490. * @param onProgress event that fires when loading progress has occured
  70491. * @param fileName Defines the name of the file to load
  70492. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70493. */
  70494. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70495. meshes: AbstractMesh[];
  70496. particleSystems: IParticleSystem[];
  70497. skeletons: Skeleton[];
  70498. animationGroups: AnimationGroup[];
  70499. }>;
  70500. /**
  70501. * Imports all objects from the loaded OBJ data and adds them to the scene
  70502. * @param scene the scene the objects should be added to
  70503. * @param data the OBJ data to load
  70504. * @param rootUrl root url to load from
  70505. * @param onProgress event that fires when loading progress has occured
  70506. * @param fileName Defines the name of the file to load
  70507. * @returns a promise which completes when objects have been loaded to the scene
  70508. */
  70509. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70510. /**
  70511. * Load into an asset container.
  70512. * @param scene The scene to load into
  70513. * @param data The data to import
  70514. * @param rootUrl The root url for scene and resources
  70515. * @param onProgress The callback when the load progresses
  70516. * @param fileName Defines the name of the file to load
  70517. * @returns The loaded asset container
  70518. */
  70519. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70520. /**
  70521. * Read the OBJ file and create an Array of meshes.
  70522. * Each mesh contains all information given by the OBJ and the MTL file.
  70523. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70524. *
  70525. * @param meshesNames
  70526. * @param scene Scene The scene where are displayed the data
  70527. * @param data String The content of the obj file
  70528. * @param rootUrl String The path to the folder
  70529. * @returns Array<AbstractMesh>
  70530. * @private
  70531. */
  70532. private _parseSolid;
  70533. }
  70534. }
  70535. declare module BABYLON {
  70536. /**
  70537. * STL file type loader.
  70538. * This is a babylon scene loader plugin.
  70539. */
  70540. export class STLFileLoader implements ISceneLoaderPlugin {
  70541. /** @hidden */
  70542. solidPattern: RegExp;
  70543. /** @hidden */
  70544. facetsPattern: RegExp;
  70545. /** @hidden */
  70546. normalPattern: RegExp;
  70547. /** @hidden */
  70548. vertexPattern: RegExp;
  70549. /**
  70550. * Defines the name of the plugin.
  70551. */
  70552. name: string;
  70553. /**
  70554. * Defines the extensions the stl loader is able to load.
  70555. * force data to come in as an ArrayBuffer
  70556. * we'll convert to string if it looks like it's an ASCII .stl
  70557. */
  70558. extensions: ISceneLoaderPluginExtensions;
  70559. /**
  70560. * Import meshes into a scene.
  70561. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70562. * @param scene The scene to import into
  70563. * @param data The data to import
  70564. * @param rootUrl The root url for scene and resources
  70565. * @param meshes The meshes array to import into
  70566. * @param particleSystems The particle systems array to import into
  70567. * @param skeletons The skeletons array to import into
  70568. * @param onError The callback when import fails
  70569. * @returns True if successful or false otherwise
  70570. */
  70571. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70572. /**
  70573. * Load into a scene.
  70574. * @param scene The scene to load into
  70575. * @param data The data to import
  70576. * @param rootUrl The root url for scene and resources
  70577. * @param onError The callback when import fails
  70578. * @returns true if successful or false otherwise
  70579. */
  70580. load(scene: Scene, data: any, rootUrl: string): boolean;
  70581. /**
  70582. * Load into an asset container.
  70583. * @param scene The scene to load into
  70584. * @param data The data to import
  70585. * @param rootUrl The root url for scene and resources
  70586. * @param onError The callback when import fails
  70587. * @returns The loaded asset container
  70588. */
  70589. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70590. private _isBinary;
  70591. private _parseBinary;
  70592. private _parseASCII;
  70593. }
  70594. }
  70595. declare module BABYLON {
  70596. /**
  70597. * Class for generating OBJ data from a Babylon scene.
  70598. */
  70599. export class OBJExport {
  70600. /**
  70601. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70602. * @param mesh defines the list of meshes to serialize
  70603. * @param materials defines if materials should be exported
  70604. * @param matlibname defines the name of the associated mtl file
  70605. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70606. * @returns the OBJ content
  70607. */
  70608. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70609. /**
  70610. * Exports the material(s) of a mesh in .MTL file format (text)
  70611. * @param mesh defines the mesh to extract the material from
  70612. * @returns the mtl content
  70613. */
  70614. static MTL(mesh: Mesh): string;
  70615. }
  70616. }
  70617. declare module BABYLON {
  70618. /** @hidden */
  70619. export var __IGLTFExporterExtension: number;
  70620. /**
  70621. * Interface for extending the exporter
  70622. * @hidden
  70623. */
  70624. export interface IGLTFExporterExtension {
  70625. /**
  70626. * The name of this extension
  70627. */
  70628. readonly name: string;
  70629. /**
  70630. * Defines whether this extension is enabled
  70631. */
  70632. enabled: boolean;
  70633. /**
  70634. * Defines whether this extension is required
  70635. */
  70636. required: boolean;
  70637. }
  70638. }
  70639. declare module BABYLON.GLTF2.Exporter {
  70640. /** @hidden */
  70641. export var __IGLTFExporterExtensionV2: number;
  70642. /**
  70643. * Interface for a glTF exporter extension
  70644. * @hidden
  70645. */
  70646. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70647. /**
  70648. * Define this method to modify the default behavior before exporting a texture
  70649. * @param context The context when loading the asset
  70650. * @param babylonTexture The glTF texture info property
  70651. * @param mimeType The mime-type of the generated image
  70652. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70653. */
  70654. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70655. /**
  70656. * Define this method to modify the default behavior when exporting texture info
  70657. * @param context The context when loading the asset
  70658. * @param meshPrimitive glTF mesh primitive
  70659. * @param babylonSubMesh Babylon submesh
  70660. * @param binaryWriter glTF serializer binary writer instance
  70661. * @returns nullable IMeshPrimitive promise
  70662. */
  70663. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70664. /**
  70665. * Define this method to modify the default behavior when exporting a node
  70666. * @param context The context when exporting the node
  70667. * @param node glTF node
  70668. * @param babylonNode BabylonJS node
  70669. * @returns nullable INode promise
  70670. */
  70671. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70672. /**
  70673. * Called after the exporter state changes to EXPORTING
  70674. */
  70675. onExporting?(): void;
  70676. }
  70677. }
  70678. declare module BABYLON.GLTF2.Exporter {
  70679. /**
  70680. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70681. * @hidden
  70682. */
  70683. export class _GLTFMaterialExporter {
  70684. /**
  70685. * Represents the dielectric specular values for R, G and B
  70686. */
  70687. private static readonly _DielectricSpecular;
  70688. /**
  70689. * Allows the maximum specular power to be defined for material calculations
  70690. */
  70691. private static readonly _MaxSpecularPower;
  70692. /**
  70693. * Mapping to store textures
  70694. */
  70695. private _textureMap;
  70696. /**
  70697. * Numeric tolerance value
  70698. */
  70699. private static readonly _Epsilon;
  70700. /**
  70701. * Reference to the glTF Exporter
  70702. */
  70703. private _exporter;
  70704. constructor(exporter: _Exporter);
  70705. /**
  70706. * Specifies if two colors are approximately equal in value
  70707. * @param color1 first color to compare to
  70708. * @param color2 second color to compare to
  70709. * @param epsilon threshold value
  70710. */
  70711. private static FuzzyEquals;
  70712. /**
  70713. * Gets the materials from a Babylon scene and converts them to glTF materials
  70714. * @param scene babylonjs scene
  70715. * @param mimeType texture mime type
  70716. * @param images array of images
  70717. * @param textures array of textures
  70718. * @param materials array of materials
  70719. * @param imageData mapping of texture names to base64 textures
  70720. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70721. */
  70722. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70723. /**
  70724. * Makes a copy of the glTF material without the texture parameters
  70725. * @param originalMaterial original glTF material
  70726. * @returns glTF material without texture parameters
  70727. */
  70728. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70729. /**
  70730. * Specifies if the material has any texture parameters present
  70731. * @param material glTF Material
  70732. * @returns boolean specifying if texture parameters are present
  70733. */
  70734. _hasTexturesPresent(material: IMaterial): boolean;
  70735. /**
  70736. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70737. * @param babylonStandardMaterial
  70738. * @returns glTF Metallic Roughness Material representation
  70739. */
  70740. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70741. /**
  70742. * Computes the metallic factor
  70743. * @param diffuse diffused value
  70744. * @param specular specular value
  70745. * @param oneMinusSpecularStrength one minus the specular strength
  70746. * @returns metallic value
  70747. */
  70748. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70749. /**
  70750. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70751. * @param glTFMaterial glTF material
  70752. * @param babylonMaterial Babylon material
  70753. */
  70754. private static _SetAlphaMode;
  70755. /**
  70756. * Converts a Babylon Standard Material to a glTF Material
  70757. * @param babylonStandardMaterial BJS Standard Material
  70758. * @param mimeType mime type to use for the textures
  70759. * @param images array of glTF image interfaces
  70760. * @param textures array of glTF texture interfaces
  70761. * @param materials array of glTF material interfaces
  70762. * @param imageData map of image file name to data
  70763. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70764. */
  70765. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70766. /**
  70767. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70768. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70769. * @param mimeType mime type to use for the textures
  70770. * @param images array of glTF image interfaces
  70771. * @param textures array of glTF texture interfaces
  70772. * @param materials array of glTF material interfaces
  70773. * @param imageData map of image file name to data
  70774. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70775. */
  70776. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70777. /**
  70778. * Converts an image typed array buffer to a base64 image
  70779. * @param buffer typed array buffer
  70780. * @param width width of the image
  70781. * @param height height of the image
  70782. * @param mimeType mimetype of the image
  70783. * @returns base64 image string
  70784. */
  70785. private _createBase64FromCanvasAsync;
  70786. /**
  70787. * Generates a white texture based on the specified width and height
  70788. * @param width width of the texture in pixels
  70789. * @param height height of the texture in pixels
  70790. * @param scene babylonjs scene
  70791. * @returns white texture
  70792. */
  70793. private _createWhiteTexture;
  70794. /**
  70795. * 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
  70796. * @param texture1 first texture to resize
  70797. * @param texture2 second texture to resize
  70798. * @param scene babylonjs scene
  70799. * @returns resized textures or null
  70800. */
  70801. private _resizeTexturesToSameDimensions;
  70802. /**
  70803. * Converts an array of pixels to a Float32Array
  70804. * Throws an error if the pixel format is not supported
  70805. * @param pixels - array buffer containing pixel values
  70806. * @returns Float32 of pixels
  70807. */
  70808. private _convertPixelArrayToFloat32;
  70809. /**
  70810. * Convert Specular Glossiness Textures to Metallic Roughness
  70811. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70812. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70813. * @param diffuseTexture texture used to store diffuse information
  70814. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70815. * @param factors specular glossiness material factors
  70816. * @param mimeType the mime type to use for the texture
  70817. * @returns pbr metallic roughness interface or null
  70818. */
  70819. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70820. /**
  70821. * Converts specular glossiness material properties to metallic roughness
  70822. * @param specularGlossiness interface with specular glossiness material properties
  70823. * @returns interface with metallic roughness material properties
  70824. */
  70825. private _convertSpecularGlossinessToMetallicRoughness;
  70826. /**
  70827. * Calculates the surface reflectance, independent of lighting conditions
  70828. * @param color Color source to calculate brightness from
  70829. * @returns number representing the perceived brightness, or zero if color is undefined
  70830. */
  70831. private _getPerceivedBrightness;
  70832. /**
  70833. * Returns the maximum color component value
  70834. * @param color
  70835. * @returns maximum color component value, or zero if color is null or undefined
  70836. */
  70837. private _getMaxComponent;
  70838. /**
  70839. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70840. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70841. * @param mimeType mime type to use for the textures
  70842. * @param images array of glTF image interfaces
  70843. * @param textures array of glTF texture interfaces
  70844. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70845. * @param imageData map of image file name to data
  70846. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70847. * @returns glTF PBR Metallic Roughness factors
  70848. */
  70849. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70850. private _getGLTFTextureSampler;
  70851. private _getGLTFTextureWrapMode;
  70852. private _getGLTFTextureWrapModesSampler;
  70853. /**
  70854. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70855. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70856. * @param mimeType mime type to use for the textures
  70857. * @param images array of glTF image interfaces
  70858. * @param textures array of glTF texture interfaces
  70859. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70860. * @param imageData map of image file name to data
  70861. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70862. * @returns glTF PBR Metallic Roughness factors
  70863. */
  70864. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70865. /**
  70866. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70867. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70868. * @param mimeType mime type to use for the textures
  70869. * @param images array of glTF image interfaces
  70870. * @param textures array of glTF texture interfaces
  70871. * @param materials array of glTF material interfaces
  70872. * @param imageData map of image file name to data
  70873. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70874. */
  70875. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70876. private setMetallicRoughnessPbrMaterial;
  70877. private getPixelsFromTexture;
  70878. /**
  70879. * Extracts a texture from a Babylon texture into file data and glTF data
  70880. * @param babylonTexture Babylon texture to extract
  70881. * @param mimeType Mime Type of the babylonTexture
  70882. * @return glTF texture info, or null if the texture format is not supported
  70883. */
  70884. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70885. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70886. /**
  70887. * Builds a texture from base64 string
  70888. * @param base64Texture base64 texture string
  70889. * @param baseTextureName Name to use for the texture
  70890. * @param mimeType image mime type for the texture
  70891. * @param images array of images
  70892. * @param textures array of textures
  70893. * @param imageData map of image data
  70894. * @returns glTF texture info, or null if the texture format is not supported
  70895. */
  70896. private _getTextureInfoFromBase64;
  70897. }
  70898. }
  70899. declare module BABYLON {
  70900. /**
  70901. * Class for holding and downloading glTF file data
  70902. */
  70903. export class GLTFData {
  70904. /**
  70905. * Object which contains the file name as the key and its data as the value
  70906. */
  70907. glTFFiles: {
  70908. [fileName: string]: string | Blob;
  70909. };
  70910. /**
  70911. * Initializes the glTF file object
  70912. */
  70913. constructor();
  70914. /**
  70915. * Downloads the glTF data as files based on their names and data
  70916. */
  70917. downloadFiles(): void;
  70918. }
  70919. }
  70920. declare module BABYLON {
  70921. /**
  70922. * Holds a collection of exporter options and parameters
  70923. */
  70924. export interface IExportOptions {
  70925. /**
  70926. * Function which indicates whether a babylon node should be exported or not
  70927. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70928. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70929. */
  70930. shouldExportNode?(node: Node): boolean;
  70931. /**
  70932. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70933. * @param metadata source metadata to read from
  70934. * @returns the data to store to glTF node extras
  70935. */
  70936. metadataSelector?(metadata: any): any;
  70937. /**
  70938. * The sample rate to bake animation curves
  70939. */
  70940. animationSampleRate?: number;
  70941. /**
  70942. * Begin serialization without waiting for the scene to be ready
  70943. */
  70944. exportWithoutWaitingForScene?: boolean;
  70945. }
  70946. /**
  70947. * Class for generating glTF data from a Babylon scene.
  70948. */
  70949. export class GLTF2Export {
  70950. /**
  70951. * Exports the geometry of the scene to .gltf file format asynchronously
  70952. * @param scene Babylon scene with scene hierarchy information
  70953. * @param filePrefix File prefix to use when generating the glTF file
  70954. * @param options Exporter options
  70955. * @returns Returns an object with a .gltf file and associates texture names
  70956. * as keys and their data and paths as values
  70957. */
  70958. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70959. private static _PreExportAsync;
  70960. private static _PostExportAsync;
  70961. /**
  70962. * Exports the geometry of the scene to .glb file format asychronously
  70963. * @param scene Babylon scene with scene hierarchy information
  70964. * @param filePrefix File prefix to use when generating glb file
  70965. * @param options Exporter options
  70966. * @returns Returns an object with a .glb filename as key and data as value
  70967. */
  70968. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70969. }
  70970. }
  70971. declare module BABYLON.GLTF2.Exporter {
  70972. /**
  70973. * @hidden
  70974. */
  70975. export class _GLTFUtilities {
  70976. /**
  70977. * Creates a buffer view based on the supplied arguments
  70978. * @param bufferIndex index value of the specified buffer
  70979. * @param byteOffset byte offset value
  70980. * @param byteLength byte length of the bufferView
  70981. * @param byteStride byte distance between conequential elements
  70982. * @param name name of the buffer view
  70983. * @returns bufferView for glTF
  70984. */
  70985. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70986. /**
  70987. * Creates an accessor based on the supplied arguments
  70988. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70989. * @param name The name of the accessor
  70990. * @param type The type of the accessor
  70991. * @param componentType The datatype of components in the attribute
  70992. * @param count The number of attributes referenced by this accessor
  70993. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70994. * @param min Minimum value of each component in this attribute
  70995. * @param max Maximum value of each component in this attribute
  70996. * @returns accessor for glTF
  70997. */
  70998. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70999. /**
  71000. * Calculates the minimum and maximum values of an array of position floats
  71001. * @param positions Positions array of a mesh
  71002. * @param vertexStart Starting vertex offset to calculate min and max values
  71003. * @param vertexCount Number of vertices to check for min and max values
  71004. * @returns min number array and max number array
  71005. */
  71006. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  71007. min: number[];
  71008. max: number[];
  71009. };
  71010. /**
  71011. * Converts a new right-handed Vector3
  71012. * @param vector vector3 array
  71013. * @returns right-handed Vector3
  71014. */
  71015. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  71016. /**
  71017. * Converts a Vector3 to right-handed
  71018. * @param vector Vector3 to convert to right-handed
  71019. */
  71020. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  71021. /**
  71022. * Converts a three element number array to right-handed
  71023. * @param vector number array to convert to right-handed
  71024. */
  71025. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  71026. /**
  71027. * Converts a new right-handed Vector3
  71028. * @param vector vector3 array
  71029. * @returns right-handed Vector3
  71030. */
  71031. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  71032. /**
  71033. * Converts a Vector3 to right-handed
  71034. * @param vector Vector3 to convert to right-handed
  71035. */
  71036. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  71037. /**
  71038. * Converts a three element number array to right-handed
  71039. * @param vector number array to convert to right-handed
  71040. */
  71041. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  71042. /**
  71043. * Converts a Vector4 to right-handed
  71044. * @param vector Vector4 to convert to right-handed
  71045. */
  71046. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  71047. /**
  71048. * Converts a Vector4 to right-handed
  71049. * @param vector Vector4 to convert to right-handed
  71050. */
  71051. static _GetRightHandedArray4FromRef(vector: number[]): void;
  71052. /**
  71053. * Converts a Quaternion to right-handed
  71054. * @param quaternion Source quaternion to convert to right-handed
  71055. */
  71056. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  71057. /**
  71058. * Converts a Quaternion to right-handed
  71059. * @param quaternion Source quaternion to convert to right-handed
  71060. */
  71061. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  71062. static _NormalizeTangentFromRef(tangent: Vector4): void;
  71063. }
  71064. }
  71065. declare module BABYLON.GLTF2.Exporter {
  71066. /**
  71067. * Converts Babylon Scene into glTF 2.0.
  71068. * @hidden
  71069. */
  71070. export class _Exporter {
  71071. /**
  71072. * Stores the glTF to export
  71073. */
  71074. _glTF: IGLTF;
  71075. /**
  71076. * Stores all generated buffer views, which represents views into the main glTF buffer data
  71077. */
  71078. _bufferViews: IBufferView[];
  71079. /**
  71080. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  71081. */
  71082. _accessors: IAccessor[];
  71083. /**
  71084. * Stores all the generated nodes, which contains transform and/or mesh information per node
  71085. */
  71086. private _nodes;
  71087. /**
  71088. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  71089. */
  71090. private _scenes;
  71091. /**
  71092. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  71093. */
  71094. private _meshes;
  71095. /**
  71096. * Stores all the generated material information, which represents the appearance of each primitive
  71097. */
  71098. _materials: IMaterial[];
  71099. _materialMap: {
  71100. [materialID: number]: number;
  71101. };
  71102. /**
  71103. * Stores all the generated texture information, which is referenced by glTF materials
  71104. */
  71105. _textures: ITexture[];
  71106. /**
  71107. * Stores all the generated image information, which is referenced by glTF textures
  71108. */
  71109. _images: IImage[];
  71110. /**
  71111. * Stores all the texture samplers
  71112. */
  71113. _samplers: ISampler[];
  71114. /**
  71115. * Stores all the generated animation samplers, which is referenced by glTF animations
  71116. */
  71117. /**
  71118. * Stores the animations for glTF models
  71119. */
  71120. private _animations;
  71121. /**
  71122. * Stores the total amount of bytes stored in the glTF buffer
  71123. */
  71124. private _totalByteLength;
  71125. /**
  71126. * Stores a reference to the Babylon scene containing the source geometry and material information
  71127. */
  71128. _babylonScene: Scene;
  71129. /**
  71130. * Stores a map of the image data, where the key is the file name and the value
  71131. * is the image data
  71132. */
  71133. _imageData: {
  71134. [fileName: string]: {
  71135. data: Uint8Array;
  71136. mimeType: ImageMimeType;
  71137. };
  71138. };
  71139. /**
  71140. * Stores a map of the unique id of a node to its index in the node array
  71141. */
  71142. private _nodeMap;
  71143. /**
  71144. * Specifies if the Babylon scene should be converted to right-handed on export
  71145. */
  71146. _convertToRightHandedSystem: boolean;
  71147. /**
  71148. * Baked animation sample rate
  71149. */
  71150. private _animationSampleRate;
  71151. private _options;
  71152. private _localEngine;
  71153. _glTFMaterialExporter: _GLTFMaterialExporter;
  71154. private _extensions;
  71155. private static _ExtensionNames;
  71156. private static _ExtensionFactories;
  71157. private _applyExtensions;
  71158. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  71159. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71160. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71161. private _forEachExtensions;
  71162. private _extensionsOnExporting;
  71163. /**
  71164. * Load glTF serializer extensions
  71165. */
  71166. private _loadExtensions;
  71167. /**
  71168. * Creates a glTF Exporter instance, which can accept optional exporter options
  71169. * @param babylonScene Babylon scene object
  71170. * @param options Options to modify the behavior of the exporter
  71171. */
  71172. constructor(babylonScene: Scene, options?: IExportOptions);
  71173. /**
  71174. * Registers a glTF exporter extension
  71175. * @param name Name of the extension to export
  71176. * @param factory The factory function that creates the exporter extension
  71177. */
  71178. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  71179. /**
  71180. * Un-registers an exporter extension
  71181. * @param name The name fo the exporter extension
  71182. * @returns A boolean indicating whether the extension has been un-registered
  71183. */
  71184. static UnregisterExtension(name: string): boolean;
  71185. /**
  71186. * Lazy load a local engine with premultiplied alpha set to false
  71187. */
  71188. _getLocalEngine(): Engine;
  71189. private reorderIndicesBasedOnPrimitiveMode;
  71190. /**
  71191. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  71192. * clock-wise during export to glTF
  71193. * @param submesh BabylonJS submesh
  71194. * @param primitiveMode Primitive mode of the mesh
  71195. * @param sideOrientation the winding order of the submesh
  71196. * @param vertexBufferKind The type of vertex attribute
  71197. * @param meshAttributeArray The vertex attribute data
  71198. * @param byteOffset The offset to the binary data
  71199. * @param binaryWriter The binary data for the glTF file
  71200. */
  71201. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  71202. /**
  71203. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  71204. * clock-wise during export to glTF
  71205. * @param submesh BabylonJS submesh
  71206. * @param primitiveMode Primitive mode of the mesh
  71207. * @param sideOrientation the winding order of the submesh
  71208. * @param vertexBufferKind The type of vertex attribute
  71209. * @param meshAttributeArray The vertex attribute data
  71210. * @param byteOffset The offset to the binary data
  71211. * @param binaryWriter The binary data for the glTF file
  71212. */
  71213. private reorderTriangleFillMode;
  71214. /**
  71215. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  71216. * clock-wise during export to glTF
  71217. * @param submesh BabylonJS submesh
  71218. * @param primitiveMode Primitive mode of the mesh
  71219. * @param sideOrientation the winding order of the submesh
  71220. * @param vertexBufferKind The type of vertex attribute
  71221. * @param meshAttributeArray The vertex attribute data
  71222. * @param byteOffset The offset to the binary data
  71223. * @param binaryWriter The binary data for the glTF file
  71224. */
  71225. private reorderTriangleStripDrawMode;
  71226. /**
  71227. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  71228. * clock-wise during export to glTF
  71229. * @param submesh BabylonJS submesh
  71230. * @param primitiveMode Primitive mode of the mesh
  71231. * @param sideOrientation the winding order of the submesh
  71232. * @param vertexBufferKind The type of vertex attribute
  71233. * @param meshAttributeArray The vertex attribute data
  71234. * @param byteOffset The offset to the binary data
  71235. * @param binaryWriter The binary data for the glTF file
  71236. */
  71237. private reorderTriangleFanMode;
  71238. /**
  71239. * Writes the vertex attribute data to binary
  71240. * @param vertices The vertices to write to the binary writer
  71241. * @param byteOffset The offset into the binary writer to overwrite binary data
  71242. * @param vertexAttributeKind The vertex attribute type
  71243. * @param meshAttributeArray The vertex attribute data
  71244. * @param binaryWriter The writer containing the binary data
  71245. */
  71246. private writeVertexAttributeData;
  71247. /**
  71248. * Writes mesh attribute data to a data buffer
  71249. * Returns the bytelength of the data
  71250. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  71251. * @param meshAttributeArray Array containing the attribute data
  71252. * @param binaryWriter The buffer to write the binary data to
  71253. * @param indices Used to specify the order of the vertex data
  71254. */
  71255. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  71256. /**
  71257. * Generates glTF json data
  71258. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  71259. * @param glTFPrefix Text to use when prefixing a glTF file
  71260. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  71261. * @returns json data as string
  71262. */
  71263. private generateJSON;
  71264. /**
  71265. * Generates data for .gltf and .bin files based on the glTF prefix string
  71266. * @param glTFPrefix Text to use when prefixing a glTF file
  71267. * @returns GLTFData with glTF file data
  71268. */
  71269. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  71270. /**
  71271. * Creates a binary buffer for glTF
  71272. * @returns array buffer for binary data
  71273. */
  71274. private _generateBinaryAsync;
  71275. /**
  71276. * Pads the number to a multiple of 4
  71277. * @param num number to pad
  71278. * @returns padded number
  71279. */
  71280. private _getPadding;
  71281. /**
  71282. * Generates a glb file from the json and binary data
  71283. * Returns an object with the glb file name as the key and data as the value
  71284. * @param glTFPrefix
  71285. * @returns object with glb filename as key and data as value
  71286. */
  71287. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  71288. /**
  71289. * Sets the TRS for each node
  71290. * @param node glTF Node for storing the transformation data
  71291. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  71292. */
  71293. private setNodeTransformation;
  71294. private getVertexBufferFromMesh;
  71295. /**
  71296. * Creates a bufferview based on the vertices type for the Babylon mesh
  71297. * @param kind Indicates the type of vertices data
  71298. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  71299. * @param binaryWriter The buffer to write the bufferview data to
  71300. */
  71301. private createBufferViewKind;
  71302. /**
  71303. * The primitive mode of the Babylon mesh
  71304. * @param babylonMesh The BabylonJS mesh
  71305. */
  71306. private getMeshPrimitiveMode;
  71307. /**
  71308. * Sets the primitive mode of the glTF mesh primitive
  71309. * @param meshPrimitive glTF mesh primitive
  71310. * @param primitiveMode The primitive mode
  71311. */
  71312. private setPrimitiveMode;
  71313. /**
  71314. * Sets the vertex attribute accessor based of the glTF mesh primitive
  71315. * @param meshPrimitive glTF mesh primitive
  71316. * @param attributeKind vertex attribute
  71317. * @returns boolean specifying if uv coordinates are present
  71318. */
  71319. private setAttributeKind;
  71320. /**
  71321. * Sets data for the primitive attributes of each submesh
  71322. * @param mesh glTF Mesh object to store the primitive attribute information
  71323. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  71324. * @param binaryWriter Buffer to write the attribute data to
  71325. */
  71326. private setPrimitiveAttributesAsync;
  71327. /**
  71328. * Creates a glTF scene based on the array of meshes
  71329. * Returns the the total byte offset
  71330. * @param babylonScene Babylon scene to get the mesh data from
  71331. * @param binaryWriter Buffer to write binary data to
  71332. */
  71333. private createSceneAsync;
  71334. /**
  71335. * Creates a mapping of Node unique id to node index and handles animations
  71336. * @param babylonScene Babylon Scene
  71337. * @param nodes Babylon transform nodes
  71338. * @param binaryWriter Buffer to write binary data to
  71339. * @returns Node mapping of unique id to index
  71340. */
  71341. private createNodeMapAndAnimationsAsync;
  71342. /**
  71343. * Creates a glTF node from a Babylon mesh
  71344. * @param babylonMesh Source Babylon mesh
  71345. * @param binaryWriter Buffer for storing geometry data
  71346. * @returns glTF node
  71347. */
  71348. private createNodeAsync;
  71349. }
  71350. /**
  71351. * @hidden
  71352. *
  71353. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71354. */
  71355. export class _BinaryWriter {
  71356. /**
  71357. * Array buffer which stores all binary data
  71358. */
  71359. private _arrayBuffer;
  71360. /**
  71361. * View of the array buffer
  71362. */
  71363. private _dataView;
  71364. /**
  71365. * byte offset of data in array buffer
  71366. */
  71367. private _byteOffset;
  71368. /**
  71369. * Initialize binary writer with an initial byte length
  71370. * @param byteLength Initial byte length of the array buffer
  71371. */
  71372. constructor(byteLength: number);
  71373. /**
  71374. * Resize the array buffer to the specified byte length
  71375. * @param byteLength
  71376. */
  71377. private resizeBuffer;
  71378. /**
  71379. * Get an array buffer with the length of the byte offset
  71380. * @returns ArrayBuffer resized to the byte offset
  71381. */
  71382. getArrayBuffer(): ArrayBuffer;
  71383. /**
  71384. * Get the byte offset of the array buffer
  71385. * @returns byte offset
  71386. */
  71387. getByteOffset(): number;
  71388. /**
  71389. * Stores an UInt8 in the array buffer
  71390. * @param entry
  71391. * @param byteOffset If defined, specifies where to set the value as an offset.
  71392. */
  71393. setUInt8(entry: number, byteOffset?: number): void;
  71394. /**
  71395. * Gets an UInt32 in the array buffer
  71396. * @param entry
  71397. * @param byteOffset If defined, specifies where to set the value as an offset.
  71398. */
  71399. getUInt32(byteOffset: number): number;
  71400. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71401. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71402. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71403. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71404. /**
  71405. * Stores a Float32 in the array buffer
  71406. * @param entry
  71407. */
  71408. setFloat32(entry: number, byteOffset?: number): void;
  71409. /**
  71410. * Stores an UInt32 in the array buffer
  71411. * @param entry
  71412. * @param byteOffset If defined, specifies where to set the value as an offset.
  71413. */
  71414. setUInt32(entry: number, byteOffset?: number): void;
  71415. }
  71416. }
  71417. declare module BABYLON.GLTF2.Exporter {
  71418. /**
  71419. * @hidden
  71420. * Interface to store animation data.
  71421. */
  71422. export interface _IAnimationData {
  71423. /**
  71424. * Keyframe data.
  71425. */
  71426. inputs: number[];
  71427. /**
  71428. * Value data.
  71429. */
  71430. outputs: number[][];
  71431. /**
  71432. * Animation interpolation data.
  71433. */
  71434. samplerInterpolation: AnimationSamplerInterpolation;
  71435. /**
  71436. * Minimum keyframe value.
  71437. */
  71438. inputsMin: number;
  71439. /**
  71440. * Maximum keyframe value.
  71441. */
  71442. inputsMax: number;
  71443. }
  71444. /**
  71445. * @hidden
  71446. */
  71447. export interface _IAnimationInfo {
  71448. /**
  71449. * The target channel for the animation
  71450. */
  71451. animationChannelTargetPath: AnimationChannelTargetPath;
  71452. /**
  71453. * The glTF accessor type for the data.
  71454. */
  71455. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71456. /**
  71457. * Specifies if quaternions should be used.
  71458. */
  71459. useQuaternion: boolean;
  71460. }
  71461. /**
  71462. * @hidden
  71463. * Utility class for generating glTF animation data from BabylonJS.
  71464. */
  71465. export class _GLTFAnimation {
  71466. /**
  71467. * @ignore
  71468. *
  71469. * Creates glTF channel animation from BabylonJS animation.
  71470. * @param babylonTransformNode - BabylonJS mesh.
  71471. * @param animation - animation.
  71472. * @param animationChannelTargetPath - The target animation channel.
  71473. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71474. * @param useQuaternion - Specifies if quaternions are used.
  71475. * @returns nullable IAnimationData
  71476. */
  71477. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71478. private static _DeduceAnimationInfo;
  71479. /**
  71480. * @ignore
  71481. * Create node animations from the transform node animations
  71482. * @param babylonNode
  71483. * @param runtimeGLTFAnimation
  71484. * @param idleGLTFAnimations
  71485. * @param nodeMap
  71486. * @param nodes
  71487. * @param binaryWriter
  71488. * @param bufferViews
  71489. * @param accessors
  71490. * @param convertToRightHandedSystem
  71491. */
  71492. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71493. [key: number]: number;
  71494. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71495. /**
  71496. * @ignore
  71497. * Create node animations from the animation groups
  71498. * @param babylonScene
  71499. * @param glTFAnimations
  71500. * @param nodeMap
  71501. * @param nodes
  71502. * @param binaryWriter
  71503. * @param bufferViews
  71504. * @param accessors
  71505. * @param convertToRightHandedSystem
  71506. */
  71507. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71508. [key: number]: number;
  71509. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71510. private static AddAnimation;
  71511. /**
  71512. * Create a baked animation
  71513. * @param babylonTransformNode BabylonJS mesh
  71514. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71515. * @param animationChannelTargetPath animation target channel
  71516. * @param minFrame minimum animation frame
  71517. * @param maxFrame maximum animation frame
  71518. * @param fps frames per second of the animation
  71519. * @param inputs input key frames of the animation
  71520. * @param outputs output key frame data of the animation
  71521. * @param convertToRightHandedSystem converts the values to right-handed
  71522. * @param useQuaternion specifies if quaternions should be used
  71523. */
  71524. private static _CreateBakedAnimation;
  71525. private static _ConvertFactorToVector3OrQuaternion;
  71526. private static _SetInterpolatedValue;
  71527. /**
  71528. * Creates linear animation from the animation key frames
  71529. * @param babylonTransformNode BabylonJS mesh
  71530. * @param animation BabylonJS animation
  71531. * @param animationChannelTargetPath The target animation channel
  71532. * @param frameDelta The difference between the last and first frame of the animation
  71533. * @param inputs Array to store the key frame times
  71534. * @param outputs Array to store the key frame data
  71535. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71536. * @param useQuaternion Specifies if quaternions are used in the animation
  71537. */
  71538. private static _CreateLinearOrStepAnimation;
  71539. /**
  71540. * Creates cubic spline animation from the animation key frames
  71541. * @param babylonTransformNode BabylonJS mesh
  71542. * @param animation BabylonJS animation
  71543. * @param animationChannelTargetPath The target animation channel
  71544. * @param frameDelta The difference between the last and first frame of the animation
  71545. * @param inputs Array to store the key frame times
  71546. * @param outputs Array to store the key frame data
  71547. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71548. * @param useQuaternion Specifies if quaternions are used in the animation
  71549. */
  71550. private static _CreateCubicSplineAnimation;
  71551. private static _GetBasePositionRotationOrScale;
  71552. /**
  71553. * Adds a key frame value
  71554. * @param keyFrame
  71555. * @param animation
  71556. * @param outputs
  71557. * @param animationChannelTargetPath
  71558. * @param basePositionRotationOrScale
  71559. * @param convertToRightHandedSystem
  71560. * @param useQuaternion
  71561. */
  71562. private static _AddKeyframeValue;
  71563. /**
  71564. * Determine the interpolation based on the key frames
  71565. * @param keyFrames
  71566. * @param animationChannelTargetPath
  71567. * @param useQuaternion
  71568. */
  71569. private static _DeduceInterpolation;
  71570. /**
  71571. * Adds an input tangent or output tangent to the output data
  71572. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71573. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71574. * @param outputs The animation data by keyframe
  71575. * @param animationChannelTargetPath The target animation channel
  71576. * @param interpolation The interpolation type
  71577. * @param keyFrame The key frame with the animation data
  71578. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71579. * @param useQuaternion Specifies if quaternions are used
  71580. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71581. */
  71582. private static AddSplineTangent;
  71583. /**
  71584. * Get the minimum and maximum key frames' frame values
  71585. * @param keyFrames animation key frames
  71586. * @returns the minimum and maximum key frame value
  71587. */
  71588. private static calculateMinMaxKeyFrames;
  71589. }
  71590. }
  71591. declare module BABYLON.GLTF2.Exporter {
  71592. /** @hidden */
  71593. export var textureTransformPixelShader: {
  71594. name: string;
  71595. shader: string;
  71596. };
  71597. }
  71598. declare module BABYLON.GLTF2.Exporter.Extensions {
  71599. /**
  71600. * @hidden
  71601. */
  71602. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71603. /** Name of this extension */
  71604. readonly name: string;
  71605. /** Defines whether this extension is enabled */
  71606. enabled: boolean;
  71607. /** Defines whether this extension is required */
  71608. required: boolean;
  71609. /** Reference to the glTF exporter */
  71610. private _exporter;
  71611. constructor(exporter: _Exporter);
  71612. dispose(): void;
  71613. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71614. /**
  71615. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71616. * @param babylonTexture
  71617. * @param offset
  71618. * @param rotation
  71619. * @param scale
  71620. * @param scene
  71621. */
  71622. private _textureTransformTextureAsync;
  71623. }
  71624. }
  71625. declare module BABYLON.GLTF2.Exporter.Extensions {
  71626. /**
  71627. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71628. */
  71629. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71630. /** The name of this extension. */
  71631. readonly name: string;
  71632. /** Defines whether this extension is enabled. */
  71633. enabled: boolean;
  71634. /** Defines whether this extension is required */
  71635. required: boolean;
  71636. /** Reference to the glTF exporter */
  71637. private _exporter;
  71638. private _lights;
  71639. /** @hidden */
  71640. constructor(exporter: _Exporter);
  71641. /** @hidden */
  71642. dispose(): void;
  71643. /** @hidden */
  71644. onExporting(): void;
  71645. /**
  71646. * Define this method to modify the default behavior when exporting a node
  71647. * @param context The context when exporting the node
  71648. * @param node glTF node
  71649. * @param babylonNode BabylonJS node
  71650. * @returns nullable INode promise
  71651. */
  71652. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71653. }
  71654. }
  71655. declare module BABYLON {
  71656. /**
  71657. * Class for generating STL data from a Babylon scene.
  71658. */
  71659. export class STLExport {
  71660. /**
  71661. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71662. * @param meshes list defines the mesh to serialize
  71663. * @param download triggers the automatic download of the file.
  71664. * @param fileName changes the downloads fileName.
  71665. * @param binary changes the STL to a binary type.
  71666. * @param isLittleEndian toggle for binary type exporter.
  71667. * @returns the STL as UTF8 string
  71668. */
  71669. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71670. }
  71671. }
  71672. declare module "babylonjs-gltf2interface" {
  71673. export = BABYLON.GLTF2;
  71674. }
  71675. /**
  71676. * Module for glTF 2.0 Interface
  71677. */
  71678. declare module BABYLON.GLTF2 {
  71679. /**
  71680. * The datatype of the components in the attribute
  71681. */
  71682. const enum AccessorComponentType {
  71683. /**
  71684. * Byte
  71685. */
  71686. BYTE = 5120,
  71687. /**
  71688. * Unsigned Byte
  71689. */
  71690. UNSIGNED_BYTE = 5121,
  71691. /**
  71692. * Short
  71693. */
  71694. SHORT = 5122,
  71695. /**
  71696. * Unsigned Short
  71697. */
  71698. UNSIGNED_SHORT = 5123,
  71699. /**
  71700. * Unsigned Int
  71701. */
  71702. UNSIGNED_INT = 5125,
  71703. /**
  71704. * Float
  71705. */
  71706. FLOAT = 5126,
  71707. }
  71708. /**
  71709. * Specifies if the attirbute is a scalar, vector, or matrix
  71710. */
  71711. const enum AccessorType {
  71712. /**
  71713. * Scalar
  71714. */
  71715. SCALAR = "SCALAR",
  71716. /**
  71717. * Vector2
  71718. */
  71719. VEC2 = "VEC2",
  71720. /**
  71721. * Vector3
  71722. */
  71723. VEC3 = "VEC3",
  71724. /**
  71725. * Vector4
  71726. */
  71727. VEC4 = "VEC4",
  71728. /**
  71729. * Matrix2x2
  71730. */
  71731. MAT2 = "MAT2",
  71732. /**
  71733. * Matrix3x3
  71734. */
  71735. MAT3 = "MAT3",
  71736. /**
  71737. * Matrix4x4
  71738. */
  71739. MAT4 = "MAT4",
  71740. }
  71741. /**
  71742. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71743. */
  71744. const enum AnimationChannelTargetPath {
  71745. /**
  71746. * Translation
  71747. */
  71748. TRANSLATION = "translation",
  71749. /**
  71750. * Rotation
  71751. */
  71752. ROTATION = "rotation",
  71753. /**
  71754. * Scale
  71755. */
  71756. SCALE = "scale",
  71757. /**
  71758. * Weights
  71759. */
  71760. WEIGHTS = "weights",
  71761. }
  71762. /**
  71763. * Interpolation algorithm
  71764. */
  71765. const enum AnimationSamplerInterpolation {
  71766. /**
  71767. * The animated values are linearly interpolated between keyframes
  71768. */
  71769. LINEAR = "LINEAR",
  71770. /**
  71771. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71772. */
  71773. STEP = "STEP",
  71774. /**
  71775. * The animation's interpolation is computed using a cubic spline with specified tangents
  71776. */
  71777. CUBICSPLINE = "CUBICSPLINE",
  71778. }
  71779. /**
  71780. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71781. */
  71782. const enum CameraType {
  71783. /**
  71784. * A perspective camera containing properties to create a perspective projection matrix
  71785. */
  71786. PERSPECTIVE = "perspective",
  71787. /**
  71788. * An orthographic camera containing properties to create an orthographic projection matrix
  71789. */
  71790. ORTHOGRAPHIC = "orthographic",
  71791. }
  71792. /**
  71793. * The mime-type of the image
  71794. */
  71795. const enum ImageMimeType {
  71796. /**
  71797. * JPEG Mime-type
  71798. */
  71799. JPEG = "image/jpeg",
  71800. /**
  71801. * PNG Mime-type
  71802. */
  71803. PNG = "image/png",
  71804. }
  71805. /**
  71806. * The alpha rendering mode of the material
  71807. */
  71808. const enum MaterialAlphaMode {
  71809. /**
  71810. * The alpha value is ignored and the rendered output is fully opaque
  71811. */
  71812. OPAQUE = "OPAQUE",
  71813. /**
  71814. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71815. */
  71816. MASK = "MASK",
  71817. /**
  71818. * 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)
  71819. */
  71820. BLEND = "BLEND",
  71821. }
  71822. /**
  71823. * The type of the primitives to render
  71824. */
  71825. const enum MeshPrimitiveMode {
  71826. /**
  71827. * Points
  71828. */
  71829. POINTS = 0,
  71830. /**
  71831. * Lines
  71832. */
  71833. LINES = 1,
  71834. /**
  71835. * Line Loop
  71836. */
  71837. LINE_LOOP = 2,
  71838. /**
  71839. * Line Strip
  71840. */
  71841. LINE_STRIP = 3,
  71842. /**
  71843. * Triangles
  71844. */
  71845. TRIANGLES = 4,
  71846. /**
  71847. * Triangle Strip
  71848. */
  71849. TRIANGLE_STRIP = 5,
  71850. /**
  71851. * Triangle Fan
  71852. */
  71853. TRIANGLE_FAN = 6,
  71854. }
  71855. /**
  71856. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71857. */
  71858. const enum TextureMagFilter {
  71859. /**
  71860. * Nearest
  71861. */
  71862. NEAREST = 9728,
  71863. /**
  71864. * Linear
  71865. */
  71866. LINEAR = 9729,
  71867. }
  71868. /**
  71869. * Minification filter. All valid values correspond to WebGL enums
  71870. */
  71871. const enum TextureMinFilter {
  71872. /**
  71873. * Nearest
  71874. */
  71875. NEAREST = 9728,
  71876. /**
  71877. * Linear
  71878. */
  71879. LINEAR = 9729,
  71880. /**
  71881. * Nearest Mip-Map Nearest
  71882. */
  71883. NEAREST_MIPMAP_NEAREST = 9984,
  71884. /**
  71885. * Linear Mipmap Nearest
  71886. */
  71887. LINEAR_MIPMAP_NEAREST = 9985,
  71888. /**
  71889. * Nearest Mipmap Linear
  71890. */
  71891. NEAREST_MIPMAP_LINEAR = 9986,
  71892. /**
  71893. * Linear Mipmap Linear
  71894. */
  71895. LINEAR_MIPMAP_LINEAR = 9987,
  71896. }
  71897. /**
  71898. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71899. */
  71900. const enum TextureWrapMode {
  71901. /**
  71902. * Clamp to Edge
  71903. */
  71904. CLAMP_TO_EDGE = 33071,
  71905. /**
  71906. * Mirrored Repeat
  71907. */
  71908. MIRRORED_REPEAT = 33648,
  71909. /**
  71910. * Repeat
  71911. */
  71912. REPEAT = 10497,
  71913. }
  71914. /**
  71915. * glTF Property
  71916. */
  71917. interface IProperty {
  71918. /**
  71919. * Dictionary object with extension-specific objects
  71920. */
  71921. extensions?: {
  71922. [key: string]: any;
  71923. };
  71924. /**
  71925. * Application-Specific data
  71926. */
  71927. extras?: any;
  71928. }
  71929. /**
  71930. * glTF Child of Root Property
  71931. */
  71932. interface IChildRootProperty extends IProperty {
  71933. /**
  71934. * The user-defined name of this object
  71935. */
  71936. name?: string;
  71937. }
  71938. /**
  71939. * Indices of those attributes that deviate from their initialization value
  71940. */
  71941. interface IAccessorSparseIndices extends IProperty {
  71942. /**
  71943. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71944. */
  71945. bufferView: number;
  71946. /**
  71947. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71948. */
  71949. byteOffset?: number;
  71950. /**
  71951. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71952. */
  71953. componentType: AccessorComponentType;
  71954. }
  71955. /**
  71956. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71957. */
  71958. interface IAccessorSparseValues extends IProperty {
  71959. /**
  71960. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71961. */
  71962. bufferView: number;
  71963. /**
  71964. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71965. */
  71966. byteOffset?: number;
  71967. }
  71968. /**
  71969. * Sparse storage of attributes that deviate from their initialization value
  71970. */
  71971. interface IAccessorSparse extends IProperty {
  71972. /**
  71973. * The number of attributes encoded in this sparse accessor
  71974. */
  71975. count: number;
  71976. /**
  71977. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71978. */
  71979. indices: IAccessorSparseIndices;
  71980. /**
  71981. * 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
  71982. */
  71983. values: IAccessorSparseValues;
  71984. }
  71985. /**
  71986. * 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
  71987. */
  71988. interface IAccessor extends IChildRootProperty {
  71989. /**
  71990. * The index of the bufferview
  71991. */
  71992. bufferView?: number;
  71993. /**
  71994. * The offset relative to the start of the bufferView in bytes
  71995. */
  71996. byteOffset?: number;
  71997. /**
  71998. * The datatype of components in the attribute
  71999. */
  72000. componentType: AccessorComponentType;
  72001. /**
  72002. * Specifies whether integer data values should be normalized
  72003. */
  72004. normalized?: boolean;
  72005. /**
  72006. * The number of attributes referenced by this accessor
  72007. */
  72008. count: number;
  72009. /**
  72010. * Specifies if the attribute is a scalar, vector, or matrix
  72011. */
  72012. type: AccessorType;
  72013. /**
  72014. * Maximum value of each component in this attribute
  72015. */
  72016. max?: number[];
  72017. /**
  72018. * Minimum value of each component in this attribute
  72019. */
  72020. min?: number[];
  72021. /**
  72022. * Sparse storage of attributes that deviate from their initialization value
  72023. */
  72024. sparse?: IAccessorSparse;
  72025. }
  72026. /**
  72027. * Targets an animation's sampler at a node's property
  72028. */
  72029. interface IAnimationChannel extends IProperty {
  72030. /**
  72031. * The index of a sampler in this animation used to compute the value for the target
  72032. */
  72033. sampler: number;
  72034. /**
  72035. * The index of the node and TRS property to target
  72036. */
  72037. target: IAnimationChannelTarget;
  72038. }
  72039. /**
  72040. * The index of the node and TRS property that an animation channel targets
  72041. */
  72042. interface IAnimationChannelTarget extends IProperty {
  72043. /**
  72044. * The index of the node to target
  72045. */
  72046. node: number;
  72047. /**
  72048. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72049. */
  72050. path: AnimationChannelTargetPath;
  72051. }
  72052. /**
  72053. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72054. */
  72055. interface IAnimationSampler extends IProperty {
  72056. /**
  72057. * The index of an accessor containing keyframe input values, e.g., time
  72058. */
  72059. input: number;
  72060. /**
  72061. * Interpolation algorithm
  72062. */
  72063. interpolation?: AnimationSamplerInterpolation;
  72064. /**
  72065. * The index of an accessor, containing keyframe output values
  72066. */
  72067. output: number;
  72068. }
  72069. /**
  72070. * A keyframe animation
  72071. */
  72072. interface IAnimation extends IChildRootProperty {
  72073. /**
  72074. * An array of channels, each of which targets an animation's sampler at a node's property
  72075. */
  72076. channels: IAnimationChannel[];
  72077. /**
  72078. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72079. */
  72080. samplers: IAnimationSampler[];
  72081. }
  72082. /**
  72083. * Metadata about the glTF asset
  72084. */
  72085. interface IAsset extends IChildRootProperty {
  72086. /**
  72087. * A copyright message suitable for display to credit the content creator
  72088. */
  72089. copyright?: string;
  72090. /**
  72091. * Tool that generated this glTF model. Useful for debugging
  72092. */
  72093. generator?: string;
  72094. /**
  72095. * The glTF version that this asset targets
  72096. */
  72097. version: string;
  72098. /**
  72099. * The minimum glTF version that this asset targets
  72100. */
  72101. minVersion?: string;
  72102. }
  72103. /**
  72104. * A buffer points to binary geometry, animation, or skins
  72105. */
  72106. interface IBuffer extends IChildRootProperty {
  72107. /**
  72108. * 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
  72109. */
  72110. uri?: string;
  72111. /**
  72112. * The length of the buffer in bytes
  72113. */
  72114. byteLength: number;
  72115. }
  72116. /**
  72117. * A view into a buffer generally representing a subset of the buffer
  72118. */
  72119. interface IBufferView extends IChildRootProperty {
  72120. /**
  72121. * The index of the buffer
  72122. */
  72123. buffer: number;
  72124. /**
  72125. * The offset into the buffer in bytes
  72126. */
  72127. byteOffset?: number;
  72128. /**
  72129. * The lenth of the bufferView in bytes
  72130. */
  72131. byteLength: number;
  72132. /**
  72133. * The stride, in bytes
  72134. */
  72135. byteStride?: number;
  72136. }
  72137. /**
  72138. * An orthographic camera containing properties to create an orthographic projection matrix
  72139. */
  72140. interface ICameraOrthographic extends IProperty {
  72141. /**
  72142. * The floating-point horizontal magnification of the view. Must not be zero
  72143. */
  72144. xmag: number;
  72145. /**
  72146. * The floating-point vertical magnification of the view. Must not be zero
  72147. */
  72148. ymag: number;
  72149. /**
  72150. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  72151. */
  72152. zfar: number;
  72153. /**
  72154. * The floating-point distance to the near clipping plane
  72155. */
  72156. znear: number;
  72157. }
  72158. /**
  72159. * A perspective camera containing properties to create a perspective projection matrix
  72160. */
  72161. interface ICameraPerspective extends IProperty {
  72162. /**
  72163. * The floating-point aspect ratio of the field of view
  72164. */
  72165. aspectRatio?: number;
  72166. /**
  72167. * The floating-point vertical field of view in radians
  72168. */
  72169. yfov: number;
  72170. /**
  72171. * The floating-point distance to the far clipping plane
  72172. */
  72173. zfar?: number;
  72174. /**
  72175. * The floating-point distance to the near clipping plane
  72176. */
  72177. znear: number;
  72178. }
  72179. /**
  72180. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72181. */
  72182. interface ICamera extends IChildRootProperty {
  72183. /**
  72184. * An orthographic camera containing properties to create an orthographic projection matrix
  72185. */
  72186. orthographic?: ICameraOrthographic;
  72187. /**
  72188. * A perspective camera containing properties to create a perspective projection matrix
  72189. */
  72190. perspective?: ICameraPerspective;
  72191. /**
  72192. * Specifies if the camera uses a perspective or orthographic projection
  72193. */
  72194. type: CameraType;
  72195. }
  72196. /**
  72197. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  72198. */
  72199. interface IImage extends IChildRootProperty {
  72200. /**
  72201. * 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
  72202. */
  72203. uri?: string;
  72204. /**
  72205. * The image's MIME type
  72206. */
  72207. mimeType?: ImageMimeType;
  72208. /**
  72209. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  72210. */
  72211. bufferView?: number;
  72212. }
  72213. /**
  72214. * Material Normal Texture Info
  72215. */
  72216. interface IMaterialNormalTextureInfo extends ITextureInfo {
  72217. /**
  72218. * The scalar multiplier applied to each normal vector of the normal texture
  72219. */
  72220. scale?: number;
  72221. }
  72222. /**
  72223. * Material Occlusion Texture Info
  72224. */
  72225. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  72226. /**
  72227. * A scalar multiplier controlling the amount of occlusion applied
  72228. */
  72229. strength?: number;
  72230. }
  72231. /**
  72232. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  72233. */
  72234. interface IMaterialPbrMetallicRoughness {
  72235. /**
  72236. * The material's base color factor
  72237. */
  72238. baseColorFactor?: number[];
  72239. /**
  72240. * The base color texture
  72241. */
  72242. baseColorTexture?: ITextureInfo;
  72243. /**
  72244. * The metalness of the material
  72245. */
  72246. metallicFactor?: number;
  72247. /**
  72248. * The roughness of the material
  72249. */
  72250. roughnessFactor?: number;
  72251. /**
  72252. * The metallic-roughness texture
  72253. */
  72254. metallicRoughnessTexture?: ITextureInfo;
  72255. }
  72256. /**
  72257. * The material appearance of a primitive
  72258. */
  72259. interface IMaterial extends IChildRootProperty {
  72260. /**
  72261. * 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
  72262. */
  72263. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72264. /**
  72265. * The normal map texture
  72266. */
  72267. normalTexture?: IMaterialNormalTextureInfo;
  72268. /**
  72269. * The occlusion map texture
  72270. */
  72271. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72272. /**
  72273. * The emissive map texture
  72274. */
  72275. emissiveTexture?: ITextureInfo;
  72276. /**
  72277. * 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
  72278. */
  72279. emissiveFactor?: number[];
  72280. /**
  72281. * The alpha rendering mode of the material
  72282. */
  72283. alphaMode?: MaterialAlphaMode;
  72284. /**
  72285. * The alpha cutoff value of the material
  72286. */
  72287. alphaCutoff?: number;
  72288. /**
  72289. * Specifies whether the material is double sided
  72290. */
  72291. doubleSided?: boolean;
  72292. }
  72293. /**
  72294. * Geometry to be rendered with the given material
  72295. */
  72296. interface IMeshPrimitive extends IProperty {
  72297. /**
  72298. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  72299. */
  72300. attributes: {
  72301. [name: string]: number;
  72302. };
  72303. /**
  72304. * The index of the accessor that contains the indices
  72305. */
  72306. indices?: number;
  72307. /**
  72308. * The index of the material to apply to this primitive when rendering
  72309. */
  72310. material?: number;
  72311. /**
  72312. * The type of primitives to render. All valid values correspond to WebGL enums
  72313. */
  72314. mode?: MeshPrimitiveMode;
  72315. /**
  72316. * 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
  72317. */
  72318. targets?: {
  72319. [name: string]: number;
  72320. }[];
  72321. }
  72322. /**
  72323. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  72324. */
  72325. interface IMesh extends IChildRootProperty {
  72326. /**
  72327. * An array of primitives, each defining geometry to be rendered with a material
  72328. */
  72329. primitives: IMeshPrimitive[];
  72330. /**
  72331. * Array of weights to be applied to the Morph Targets
  72332. */
  72333. weights?: number[];
  72334. }
  72335. /**
  72336. * A node in the node hierarchy
  72337. */
  72338. interface INode extends IChildRootProperty {
  72339. /**
  72340. * The index of the camera referenced by this node
  72341. */
  72342. camera?: number;
  72343. /**
  72344. * The indices of this node's children
  72345. */
  72346. children?: number[];
  72347. /**
  72348. * The index of the skin referenced by this node
  72349. */
  72350. skin?: number;
  72351. /**
  72352. * A floating-point 4x4 transformation matrix stored in column-major order
  72353. */
  72354. matrix?: number[];
  72355. /**
  72356. * The index of the mesh in this node
  72357. */
  72358. mesh?: number;
  72359. /**
  72360. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72361. */
  72362. rotation?: number[];
  72363. /**
  72364. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72365. */
  72366. scale?: number[];
  72367. /**
  72368. * The node's translation along the x, y, and z axes
  72369. */
  72370. translation?: number[];
  72371. /**
  72372. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72373. */
  72374. weights?: number[];
  72375. }
  72376. /**
  72377. * Texture sampler properties for filtering and wrapping modes
  72378. */
  72379. interface ISampler extends IChildRootProperty {
  72380. /**
  72381. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72382. */
  72383. magFilter?: TextureMagFilter;
  72384. /**
  72385. * Minification filter. All valid values correspond to WebGL enums
  72386. */
  72387. minFilter?: TextureMinFilter;
  72388. /**
  72389. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72390. */
  72391. wrapS?: TextureWrapMode;
  72392. /**
  72393. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72394. */
  72395. wrapT?: TextureWrapMode;
  72396. }
  72397. /**
  72398. * The root nodes of a scene
  72399. */
  72400. interface IScene extends IChildRootProperty {
  72401. /**
  72402. * The indices of each root node
  72403. */
  72404. nodes: number[];
  72405. }
  72406. /**
  72407. * Joints and matrices defining a skin
  72408. */
  72409. interface ISkin extends IChildRootProperty {
  72410. /**
  72411. * 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
  72412. */
  72413. inverseBindMatrices?: number;
  72414. /**
  72415. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72416. */
  72417. skeleton?: number;
  72418. /**
  72419. * 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)
  72420. */
  72421. joints: number[];
  72422. }
  72423. /**
  72424. * A texture and its sampler
  72425. */
  72426. interface ITexture extends IChildRootProperty {
  72427. /**
  72428. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72429. */
  72430. sampler?: number;
  72431. /**
  72432. * The index of the image used by this texture
  72433. */
  72434. source: number;
  72435. }
  72436. /**
  72437. * Reference to a texture
  72438. */
  72439. interface ITextureInfo extends IProperty {
  72440. /**
  72441. * The index of the texture
  72442. */
  72443. index: number;
  72444. /**
  72445. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72446. */
  72447. texCoord?: number;
  72448. }
  72449. /**
  72450. * The root object for a glTF asset
  72451. */
  72452. interface IGLTF extends IProperty {
  72453. /**
  72454. * An array of accessors. An accessor is a typed view into a bufferView
  72455. */
  72456. accessors?: IAccessor[];
  72457. /**
  72458. * An array of keyframe animations
  72459. */
  72460. animations?: IAnimation[];
  72461. /**
  72462. * Metadata about the glTF asset
  72463. */
  72464. asset: IAsset;
  72465. /**
  72466. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72467. */
  72468. buffers?: IBuffer[];
  72469. /**
  72470. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72471. */
  72472. bufferViews?: IBufferView[];
  72473. /**
  72474. * An array of cameras
  72475. */
  72476. cameras?: ICamera[];
  72477. /**
  72478. * Names of glTF extensions used somewhere in this asset
  72479. */
  72480. extensionsUsed?: string[];
  72481. /**
  72482. * Names of glTF extensions required to properly load this asset
  72483. */
  72484. extensionsRequired?: string[];
  72485. /**
  72486. * An array of images. An image defines data used to create a texture
  72487. */
  72488. images?: IImage[];
  72489. /**
  72490. * An array of materials. A material defines the appearance of a primitive
  72491. */
  72492. materials?: IMaterial[];
  72493. /**
  72494. * An array of meshes. A mesh is a set of primitives to be rendered
  72495. */
  72496. meshes?: IMesh[];
  72497. /**
  72498. * An array of nodes
  72499. */
  72500. nodes?: INode[];
  72501. /**
  72502. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72503. */
  72504. samplers?: ISampler[];
  72505. /**
  72506. * The index of the default scene
  72507. */
  72508. scene?: number;
  72509. /**
  72510. * An array of scenes
  72511. */
  72512. scenes?: IScene[];
  72513. /**
  72514. * An array of skins. A skin is defined by joints and matrices
  72515. */
  72516. skins?: ISkin[];
  72517. /**
  72518. * An array of textures
  72519. */
  72520. textures?: ITexture[];
  72521. }
  72522. /**
  72523. * The glTF validation results
  72524. * @ignore
  72525. */
  72526. interface IGLTFValidationResults {
  72527. info: {
  72528. generator: string;
  72529. hasAnimations: boolean;
  72530. hasDefaultScene: boolean;
  72531. hasMaterials: boolean;
  72532. hasMorphTargets: boolean;
  72533. hasSkins: boolean;
  72534. hasTextures: boolean;
  72535. maxAttributesUsed: number;
  72536. primitivesCount: number
  72537. };
  72538. issues: {
  72539. messages: Array<string>;
  72540. numErrors: number;
  72541. numHints: number;
  72542. numInfos: number;
  72543. numWarnings: number;
  72544. truncated: boolean
  72545. };
  72546. mimeType: string;
  72547. uri: string;
  72548. validatedAt: string;
  72549. validatorVersion: string;
  72550. }
  72551. /**
  72552. * The glTF validation options
  72553. */
  72554. interface IGLTFValidationOptions {
  72555. /** Uri to use */
  72556. uri?: string;
  72557. /** Function used to load external resources */
  72558. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72559. /** Boolean indicating that we need to validate accessor data */
  72560. validateAccessorData?: boolean;
  72561. /** max number of issues allowed */
  72562. maxIssues?: number;
  72563. /** Ignored issues */
  72564. ignoredIssues?: Array<string>;
  72565. /** Value to override severy settings */
  72566. severityOverrides?: Object;
  72567. }
  72568. /**
  72569. * The glTF validator object
  72570. * @ignore
  72571. */
  72572. interface IGLTFValidator {
  72573. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72574. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. /** @hidden */
  72579. export var cellPixelShader: {
  72580. name: string;
  72581. shader: string;
  72582. };
  72583. }
  72584. declare module BABYLON {
  72585. /** @hidden */
  72586. export var cellVertexShader: {
  72587. name: string;
  72588. shader: string;
  72589. };
  72590. }
  72591. declare module BABYLON {
  72592. export class CellMaterial extends BABYLON.PushMaterial {
  72593. private _diffuseTexture;
  72594. diffuseTexture: BABYLON.BaseTexture;
  72595. diffuseColor: BABYLON.Color3;
  72596. _computeHighLevel: boolean;
  72597. computeHighLevel: boolean;
  72598. private _disableLighting;
  72599. disableLighting: boolean;
  72600. private _maxSimultaneousLights;
  72601. maxSimultaneousLights: number;
  72602. private _renderId;
  72603. constructor(name: string, scene: BABYLON.Scene);
  72604. needAlphaBlending(): boolean;
  72605. needAlphaTesting(): boolean;
  72606. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72608. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72609. getAnimatables(): BABYLON.IAnimatable[];
  72610. getActiveTextures(): BABYLON.BaseTexture[];
  72611. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72612. dispose(forceDisposeEffect?: boolean): void;
  72613. getClassName(): string;
  72614. clone(name: string): CellMaterial;
  72615. serialize(): any;
  72616. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72617. }
  72618. }
  72619. declare module BABYLON {
  72620. export class CustomShaderStructure {
  72621. FragmentStore: string;
  72622. VertexStore: string;
  72623. constructor();
  72624. }
  72625. export class ShaderSpecialParts {
  72626. constructor();
  72627. Fragment_Begin: string;
  72628. Fragment_Definitions: string;
  72629. Fragment_MainBegin: string;
  72630. Fragment_Custom_Diffuse: string;
  72631. Fragment_Before_Lights: string;
  72632. Fragment_Before_Fog: string;
  72633. Fragment_Custom_Alpha: string;
  72634. Fragment_Before_FragColor: string;
  72635. Vertex_Begin: string;
  72636. Vertex_Definitions: string;
  72637. Vertex_MainBegin: string;
  72638. Vertex_Before_PositionUpdated: string;
  72639. Vertex_Before_NormalUpdated: string;
  72640. Vertex_MainEnd: string;
  72641. }
  72642. export class CustomMaterial extends BABYLON.StandardMaterial {
  72643. static ShaderIndexer: number;
  72644. CustomParts: ShaderSpecialParts;
  72645. _isCreatedShader: boolean;
  72646. _createdShaderName: string;
  72647. _customUniform: string[];
  72648. _newUniforms: string[];
  72649. _newUniformInstances: any[];
  72650. _newSamplerInstances: BABYLON.Texture[];
  72651. FragmentShader: string;
  72652. VertexShader: string;
  72653. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72654. ReviewUniform(name: string, arr: string[]): string[];
  72655. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72656. constructor(name: string, scene: BABYLON.Scene);
  72657. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72658. Fragment_Begin(shaderPart: string): CustomMaterial;
  72659. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72660. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72661. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72662. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72663. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72664. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72665. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72666. Vertex_Begin(shaderPart: string): CustomMaterial;
  72667. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72668. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72669. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72670. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72671. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72672. }
  72673. }
  72674. declare module BABYLON {
  72675. export class ShaderAlebdoParts {
  72676. constructor();
  72677. Fragment_Begin: string;
  72678. Fragment_Definitions: string;
  72679. Fragment_MainBegin: string;
  72680. Fragment_Custom_Albedo: string;
  72681. Fragment_Before_Lights: string;
  72682. Fragment_Custom_MetallicRoughness: string;
  72683. Fragment_Custom_MicroSurface: string;
  72684. Fragment_Before_Fog: string;
  72685. Fragment_Custom_Alpha: string;
  72686. Fragment_Before_FragColor: string;
  72687. Vertex_Begin: string;
  72688. Vertex_Definitions: string;
  72689. Vertex_MainBegin: string;
  72690. Vertex_Before_PositionUpdated: string;
  72691. Vertex_Before_NormalUpdated: string;
  72692. Vertex_MainEnd: string;
  72693. }
  72694. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72695. static ShaderIndexer: number;
  72696. CustomParts: ShaderAlebdoParts;
  72697. _isCreatedShader: boolean;
  72698. _createdShaderName: string;
  72699. _customUniform: string[];
  72700. _newUniforms: string[];
  72701. _newUniformInstances: any[];
  72702. _newSamplerInstances: BABYLON.Texture[];
  72703. FragmentShader: string;
  72704. VertexShader: string;
  72705. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72706. ReviewUniform(name: string, arr: string[]): string[];
  72707. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72708. constructor(name: string, scene: BABYLON.Scene);
  72709. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72710. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72711. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72712. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72713. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72714. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72715. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72716. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72717. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72718. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72719. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72720. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72721. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72722. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72723. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72724. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72725. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72726. }
  72727. }
  72728. declare module BABYLON {
  72729. /** @hidden */
  72730. export var firePixelShader: {
  72731. name: string;
  72732. shader: string;
  72733. };
  72734. }
  72735. declare module BABYLON {
  72736. /** @hidden */
  72737. export var fireVertexShader: {
  72738. name: string;
  72739. shader: string;
  72740. };
  72741. }
  72742. declare module BABYLON {
  72743. export class FireMaterial extends BABYLON.PushMaterial {
  72744. private _diffuseTexture;
  72745. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72746. private _distortionTexture;
  72747. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72748. private _opacityTexture;
  72749. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72750. diffuseColor: BABYLON.Color3;
  72751. speed: number;
  72752. private _scaledDiffuse;
  72753. private _renderId;
  72754. private _lastTime;
  72755. constructor(name: string, scene: BABYLON.Scene);
  72756. needAlphaBlending(): boolean;
  72757. needAlphaTesting(): boolean;
  72758. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72759. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72760. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72761. getAnimatables(): BABYLON.IAnimatable[];
  72762. getActiveTextures(): BABYLON.BaseTexture[];
  72763. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72764. getClassName(): string;
  72765. dispose(forceDisposeEffect?: boolean): void;
  72766. clone(name: string): FireMaterial;
  72767. serialize(): any;
  72768. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72769. }
  72770. }
  72771. declare module BABYLON {
  72772. /** @hidden */
  72773. export var furPixelShader: {
  72774. name: string;
  72775. shader: string;
  72776. };
  72777. }
  72778. declare module BABYLON {
  72779. /** @hidden */
  72780. export var furVertexShader: {
  72781. name: string;
  72782. shader: string;
  72783. };
  72784. }
  72785. declare module BABYLON {
  72786. export class FurMaterial extends BABYLON.PushMaterial {
  72787. private _diffuseTexture;
  72788. diffuseTexture: BABYLON.BaseTexture;
  72789. private _heightTexture;
  72790. heightTexture: BABYLON.BaseTexture;
  72791. diffuseColor: BABYLON.Color3;
  72792. furLength: number;
  72793. furAngle: number;
  72794. furColor: BABYLON.Color3;
  72795. furOffset: number;
  72796. furSpacing: number;
  72797. furGravity: BABYLON.Vector3;
  72798. furSpeed: number;
  72799. furDensity: number;
  72800. furOcclusion: number;
  72801. furTexture: BABYLON.DynamicTexture;
  72802. private _disableLighting;
  72803. disableLighting: boolean;
  72804. private _maxSimultaneousLights;
  72805. maxSimultaneousLights: number;
  72806. highLevelFur: boolean;
  72807. _meshes: BABYLON.AbstractMesh[];
  72808. private _renderId;
  72809. private _furTime;
  72810. constructor(name: string, scene: BABYLON.Scene);
  72811. furTime: number;
  72812. needAlphaBlending(): boolean;
  72813. needAlphaTesting(): boolean;
  72814. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72815. updateFur(): void;
  72816. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72817. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72818. getAnimatables(): BABYLON.IAnimatable[];
  72819. getActiveTextures(): BABYLON.BaseTexture[];
  72820. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72821. dispose(forceDisposeEffect?: boolean): void;
  72822. clone(name: string): FurMaterial;
  72823. serialize(): any;
  72824. getClassName(): string;
  72825. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72826. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72827. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72828. }
  72829. }
  72830. declare module BABYLON {
  72831. /** @hidden */
  72832. export var gradientPixelShader: {
  72833. name: string;
  72834. shader: string;
  72835. };
  72836. }
  72837. declare module BABYLON {
  72838. /** @hidden */
  72839. export var gradientVertexShader: {
  72840. name: string;
  72841. shader: string;
  72842. };
  72843. }
  72844. declare module BABYLON {
  72845. export class GradientMaterial extends BABYLON.PushMaterial {
  72846. private _maxSimultaneousLights;
  72847. maxSimultaneousLights: number;
  72848. topColor: BABYLON.Color3;
  72849. topColorAlpha: number;
  72850. bottomColor: BABYLON.Color3;
  72851. bottomColorAlpha: number;
  72852. offset: number;
  72853. scale: number;
  72854. smoothness: number;
  72855. private _disableLighting;
  72856. disableLighting: boolean;
  72857. private _renderId;
  72858. constructor(name: string, scene: BABYLON.Scene);
  72859. needAlphaBlending(): boolean;
  72860. needAlphaTesting(): boolean;
  72861. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72862. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72863. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72864. getAnimatables(): BABYLON.IAnimatable[];
  72865. dispose(forceDisposeEffect?: boolean): void;
  72866. clone(name: string): GradientMaterial;
  72867. serialize(): any;
  72868. getClassName(): string;
  72869. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72870. }
  72871. }
  72872. declare module BABYLON {
  72873. /** @hidden */
  72874. export var gridPixelShader: {
  72875. name: string;
  72876. shader: string;
  72877. };
  72878. }
  72879. declare module BABYLON {
  72880. /** @hidden */
  72881. export var gridVertexShader: {
  72882. name: string;
  72883. shader: string;
  72884. };
  72885. }
  72886. declare module BABYLON {
  72887. /**
  72888. * The grid materials allows you to wrap any shape with a grid.
  72889. * Colors are customizable.
  72890. */
  72891. export class GridMaterial extends BABYLON.PushMaterial {
  72892. /**
  72893. * Main color of the grid (e.g. between lines)
  72894. */
  72895. mainColor: BABYLON.Color3;
  72896. /**
  72897. * Color of the grid lines.
  72898. */
  72899. lineColor: BABYLON.Color3;
  72900. /**
  72901. * The scale of the grid compared to unit.
  72902. */
  72903. gridRatio: number;
  72904. /**
  72905. * Allows setting an offset for the grid lines.
  72906. */
  72907. gridOffset: BABYLON.Vector3;
  72908. /**
  72909. * The frequency of thicker lines.
  72910. */
  72911. majorUnitFrequency: number;
  72912. /**
  72913. * The visibility of minor units in the grid.
  72914. */
  72915. minorUnitVisibility: number;
  72916. /**
  72917. * The grid opacity outside of the lines.
  72918. */
  72919. opacity: number;
  72920. /**
  72921. * Determine RBG output is premultiplied by alpha value.
  72922. */
  72923. preMultiplyAlpha: boolean;
  72924. private _opacityTexture;
  72925. opacityTexture: BABYLON.BaseTexture;
  72926. private _gridControl;
  72927. private _renderId;
  72928. /**
  72929. * constructor
  72930. * @param name The name given to the material in order to identify it afterwards.
  72931. * @param scene The scene the material is used in.
  72932. */
  72933. constructor(name: string, scene: BABYLON.Scene);
  72934. /**
  72935. * Returns wehter or not the grid requires alpha blending.
  72936. */
  72937. needAlphaBlending(): boolean;
  72938. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72939. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72940. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72941. /**
  72942. * Dispose the material and its associated resources.
  72943. * @param forceDisposeEffect will also dispose the used effect when true
  72944. */
  72945. dispose(forceDisposeEffect?: boolean): void;
  72946. clone(name: string): GridMaterial;
  72947. serialize(): any;
  72948. getClassName(): string;
  72949. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72950. }
  72951. }
  72952. declare module BABYLON {
  72953. /** @hidden */
  72954. export var lavaPixelShader: {
  72955. name: string;
  72956. shader: string;
  72957. };
  72958. }
  72959. declare module BABYLON {
  72960. /** @hidden */
  72961. export var lavaVertexShader: {
  72962. name: string;
  72963. shader: string;
  72964. };
  72965. }
  72966. declare module BABYLON {
  72967. export class LavaMaterial extends BABYLON.PushMaterial {
  72968. private _diffuseTexture;
  72969. diffuseTexture: BABYLON.BaseTexture;
  72970. noiseTexture: BABYLON.BaseTexture;
  72971. fogColor: BABYLON.Color3;
  72972. speed: number;
  72973. movingSpeed: number;
  72974. lowFrequencySpeed: number;
  72975. fogDensity: number;
  72976. private _lastTime;
  72977. diffuseColor: BABYLON.Color3;
  72978. private _disableLighting;
  72979. disableLighting: boolean;
  72980. private _unlit;
  72981. unlit: boolean;
  72982. private _maxSimultaneousLights;
  72983. maxSimultaneousLights: number;
  72984. private _scaledDiffuse;
  72985. private _renderId;
  72986. constructor(name: string, scene: BABYLON.Scene);
  72987. needAlphaBlending(): boolean;
  72988. needAlphaTesting(): boolean;
  72989. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72990. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72991. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72992. getAnimatables(): BABYLON.IAnimatable[];
  72993. getActiveTextures(): BABYLON.BaseTexture[];
  72994. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72995. dispose(forceDisposeEffect?: boolean): void;
  72996. clone(name: string): LavaMaterial;
  72997. serialize(): any;
  72998. getClassName(): string;
  72999. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  73000. }
  73001. }
  73002. declare module BABYLON {
  73003. /** @hidden */
  73004. export var mixPixelShader: {
  73005. name: string;
  73006. shader: string;
  73007. };
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var mixVertexShader: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. export class MixMaterial extends BABYLON.PushMaterial {
  73018. /**
  73019. * Mix textures
  73020. */
  73021. private _mixTexture1;
  73022. mixTexture1: BABYLON.BaseTexture;
  73023. private _mixTexture2;
  73024. mixTexture2: BABYLON.BaseTexture;
  73025. /**
  73026. * Diffuse textures
  73027. */
  73028. private _diffuseTexture1;
  73029. diffuseTexture1: BABYLON.Texture;
  73030. private _diffuseTexture2;
  73031. diffuseTexture2: BABYLON.Texture;
  73032. private _diffuseTexture3;
  73033. diffuseTexture3: BABYLON.Texture;
  73034. private _diffuseTexture4;
  73035. diffuseTexture4: BABYLON.Texture;
  73036. private _diffuseTexture5;
  73037. diffuseTexture5: BABYLON.Texture;
  73038. private _diffuseTexture6;
  73039. diffuseTexture6: BABYLON.Texture;
  73040. private _diffuseTexture7;
  73041. diffuseTexture7: BABYLON.Texture;
  73042. private _diffuseTexture8;
  73043. diffuseTexture8: BABYLON.Texture;
  73044. /**
  73045. * Uniforms
  73046. */
  73047. diffuseColor: BABYLON.Color3;
  73048. specularColor: BABYLON.Color3;
  73049. specularPower: number;
  73050. private _disableLighting;
  73051. disableLighting: boolean;
  73052. private _maxSimultaneousLights;
  73053. maxSimultaneousLights: number;
  73054. private _renderId;
  73055. constructor(name: string, scene: BABYLON.Scene);
  73056. needAlphaBlending(): boolean;
  73057. needAlphaTesting(): boolean;
  73058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73059. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73060. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73061. getAnimatables(): BABYLON.IAnimatable[];
  73062. getActiveTextures(): BABYLON.BaseTexture[];
  73063. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73064. dispose(forceDisposeEffect?: boolean): void;
  73065. clone(name: string): MixMaterial;
  73066. serialize(): any;
  73067. getClassName(): string;
  73068. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  73069. }
  73070. }
  73071. declare module BABYLON {
  73072. /** @hidden */
  73073. export var normalPixelShader: {
  73074. name: string;
  73075. shader: string;
  73076. };
  73077. }
  73078. declare module BABYLON {
  73079. /** @hidden */
  73080. export var normalVertexShader: {
  73081. name: string;
  73082. shader: string;
  73083. };
  73084. }
  73085. declare module BABYLON {
  73086. export class NormalMaterial extends BABYLON.PushMaterial {
  73087. private _diffuseTexture;
  73088. diffuseTexture: BABYLON.BaseTexture;
  73089. diffuseColor: BABYLON.Color3;
  73090. private _disableLighting;
  73091. disableLighting: boolean;
  73092. private _maxSimultaneousLights;
  73093. maxSimultaneousLights: number;
  73094. private _renderId;
  73095. constructor(name: string, scene: BABYLON.Scene);
  73096. needAlphaBlending(): boolean;
  73097. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73098. needAlphaTesting(): boolean;
  73099. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73100. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73101. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73102. getAnimatables(): BABYLON.IAnimatable[];
  73103. getActiveTextures(): BABYLON.BaseTexture[];
  73104. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73105. dispose(forceDisposeEffect?: boolean): void;
  73106. clone(name: string): NormalMaterial;
  73107. serialize(): any;
  73108. getClassName(): string;
  73109. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  73110. }
  73111. }
  73112. declare module BABYLON {
  73113. /** @hidden */
  73114. export var shadowOnlyPixelShader: {
  73115. name: string;
  73116. shader: string;
  73117. };
  73118. }
  73119. declare module BABYLON {
  73120. /** @hidden */
  73121. export var shadowOnlyVertexShader: {
  73122. name: string;
  73123. shader: string;
  73124. };
  73125. }
  73126. declare module BABYLON {
  73127. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  73128. private _renderId;
  73129. private _activeLight;
  73130. constructor(name: string, scene: BABYLON.Scene);
  73131. shadowColor: BABYLON.Color3;
  73132. needAlphaBlending(): boolean;
  73133. needAlphaTesting(): boolean;
  73134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73135. activeLight: BABYLON.IShadowLight;
  73136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73138. clone(name: string): ShadowOnlyMaterial;
  73139. serialize(): any;
  73140. getClassName(): string;
  73141. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  73142. }
  73143. }
  73144. declare module BABYLON {
  73145. /** @hidden */
  73146. export var simplePixelShader: {
  73147. name: string;
  73148. shader: string;
  73149. };
  73150. }
  73151. declare module BABYLON {
  73152. /** @hidden */
  73153. export var simpleVertexShader: {
  73154. name: string;
  73155. shader: string;
  73156. };
  73157. }
  73158. declare module BABYLON {
  73159. export class SimpleMaterial extends BABYLON.PushMaterial {
  73160. private _diffuseTexture;
  73161. diffuseTexture: BABYLON.BaseTexture;
  73162. diffuseColor: BABYLON.Color3;
  73163. private _disableLighting;
  73164. disableLighting: boolean;
  73165. private _maxSimultaneousLights;
  73166. maxSimultaneousLights: number;
  73167. private _renderId;
  73168. constructor(name: string, scene: BABYLON.Scene);
  73169. needAlphaBlending(): boolean;
  73170. needAlphaTesting(): boolean;
  73171. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73172. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73173. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73174. getAnimatables(): BABYLON.IAnimatable[];
  73175. getActiveTextures(): BABYLON.BaseTexture[];
  73176. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73177. dispose(forceDisposeEffect?: boolean): void;
  73178. clone(name: string): SimpleMaterial;
  73179. serialize(): any;
  73180. getClassName(): string;
  73181. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  73182. }
  73183. }
  73184. declare module BABYLON {
  73185. /** @hidden */
  73186. export var skyPixelShader: {
  73187. name: string;
  73188. shader: string;
  73189. };
  73190. }
  73191. declare module BABYLON {
  73192. /** @hidden */
  73193. export var skyVertexShader: {
  73194. name: string;
  73195. shader: string;
  73196. };
  73197. }
  73198. declare module BABYLON {
  73199. /**
  73200. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  73201. * @see https://doc.babylonjs.com/extensions/sky
  73202. */
  73203. export class SkyMaterial extends BABYLON.PushMaterial {
  73204. /**
  73205. * Defines the overall luminance of sky in interval ]0, 1[.
  73206. */
  73207. luminance: number;
  73208. /**
  73209. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  73210. */
  73211. turbidity: number;
  73212. /**
  73213. * Defines the sky appearance (light intensity).
  73214. */
  73215. rayleigh: number;
  73216. /**
  73217. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  73218. */
  73219. mieCoefficient: number;
  73220. /**
  73221. * Defines the amount of haze particles following the Mie scattering theory.
  73222. */
  73223. mieDirectionalG: number;
  73224. /**
  73225. * Defines the distance of the sun according to the active scene camera.
  73226. */
  73227. distance: number;
  73228. /**
  73229. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  73230. * "inclined".
  73231. */
  73232. inclination: number;
  73233. /**
  73234. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  73235. * an object direction and a reference direction.
  73236. */
  73237. azimuth: number;
  73238. /**
  73239. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  73240. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  73241. */
  73242. sunPosition: BABYLON.Vector3;
  73243. /**
  73244. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  73245. * .sunPosition property.
  73246. */
  73247. useSunPosition: boolean;
  73248. /**
  73249. * Defines an offset vector used to get a horizon offset.
  73250. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  73251. */
  73252. cameraOffset: BABYLON.Vector3;
  73253. private _cameraPosition;
  73254. private _renderId;
  73255. /**
  73256. * Instantiates a new sky material.
  73257. * This material allows to create dynamic and texture free
  73258. * effects for skyboxes by taking care of the atmosphere state.
  73259. * @see https://doc.babylonjs.com/extensions/sky
  73260. * @param name Define the name of the material in the scene
  73261. * @param scene Define the scene the material belong to
  73262. */
  73263. constructor(name: string, scene: BABYLON.Scene);
  73264. /**
  73265. * Specifies if the material will require alpha blending
  73266. * @returns a boolean specifying if alpha blending is needed
  73267. */
  73268. needAlphaBlending(): boolean;
  73269. /**
  73270. * Specifies if this material should be rendered in alpha test mode
  73271. * @returns false as the sky material doesn't need alpha testing.
  73272. */
  73273. needAlphaTesting(): boolean;
  73274. /**
  73275. * Get the texture used for alpha test purpose.
  73276. * @returns null as the sky material has no texture.
  73277. */
  73278. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73279. /**
  73280. * Get if the submesh is ready to be used and all its information available.
  73281. * Child classes can use it to update shaders
  73282. * @param mesh defines the mesh to check
  73283. * @param subMesh defines which submesh to check
  73284. * @param useInstances specifies that instances should be used
  73285. * @returns a boolean indicating that the submesh is ready or not
  73286. */
  73287. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73288. /**
  73289. * Binds the submesh to this material by preparing the effect and shader to draw
  73290. * @param world defines the world transformation matrix
  73291. * @param mesh defines the mesh containing the submesh
  73292. * @param subMesh defines the submesh to bind the material to
  73293. */
  73294. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73295. /**
  73296. * Get the list of animatables in the material.
  73297. * @returns the list of animatables object used in the material
  73298. */
  73299. getAnimatables(): BABYLON.IAnimatable[];
  73300. /**
  73301. * Disposes the material
  73302. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73303. */
  73304. dispose(forceDisposeEffect?: boolean): void;
  73305. /**
  73306. * Makes a duplicate of the material, and gives it a new name
  73307. * @param name defines the new name for the duplicated material
  73308. * @returns the cloned material
  73309. */
  73310. clone(name: string): SkyMaterial;
  73311. /**
  73312. * Serializes this material in a JSON representation
  73313. * @returns the serialized material object
  73314. */
  73315. serialize(): any;
  73316. /**
  73317. * Gets the current class name of the material e.g. "SkyMaterial"
  73318. * Mainly use in serialization.
  73319. * @returns the class name
  73320. */
  73321. getClassName(): string;
  73322. /**
  73323. * Creates a sky material from parsed material data
  73324. * @param source defines the JSON representation of the material
  73325. * @param scene defines the hosting scene
  73326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73327. * @returns a new sky material
  73328. */
  73329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73330. }
  73331. }
  73332. declare module BABYLON {
  73333. /** @hidden */
  73334. export var terrainPixelShader: {
  73335. name: string;
  73336. shader: string;
  73337. };
  73338. }
  73339. declare module BABYLON {
  73340. /** @hidden */
  73341. export var terrainVertexShader: {
  73342. name: string;
  73343. shader: string;
  73344. };
  73345. }
  73346. declare module BABYLON {
  73347. export class TerrainMaterial extends BABYLON.PushMaterial {
  73348. private _mixTexture;
  73349. mixTexture: BABYLON.BaseTexture;
  73350. private _diffuseTexture1;
  73351. diffuseTexture1: BABYLON.Texture;
  73352. private _diffuseTexture2;
  73353. diffuseTexture2: BABYLON.Texture;
  73354. private _diffuseTexture3;
  73355. diffuseTexture3: BABYLON.Texture;
  73356. private _bumpTexture1;
  73357. bumpTexture1: BABYLON.Texture;
  73358. private _bumpTexture2;
  73359. bumpTexture2: BABYLON.Texture;
  73360. private _bumpTexture3;
  73361. bumpTexture3: BABYLON.Texture;
  73362. diffuseColor: BABYLON.Color3;
  73363. specularColor: BABYLON.Color3;
  73364. specularPower: number;
  73365. private _disableLighting;
  73366. disableLighting: boolean;
  73367. private _maxSimultaneousLights;
  73368. maxSimultaneousLights: number;
  73369. private _renderId;
  73370. constructor(name: string, scene: BABYLON.Scene);
  73371. needAlphaBlending(): boolean;
  73372. needAlphaTesting(): boolean;
  73373. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73374. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73375. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73376. getAnimatables(): BABYLON.IAnimatable[];
  73377. getActiveTextures(): BABYLON.BaseTexture[];
  73378. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73379. dispose(forceDisposeEffect?: boolean): void;
  73380. clone(name: string): TerrainMaterial;
  73381. serialize(): any;
  73382. getClassName(): string;
  73383. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73384. }
  73385. }
  73386. declare module BABYLON {
  73387. /** @hidden */
  73388. export var triplanarPixelShader: {
  73389. name: string;
  73390. shader: string;
  73391. };
  73392. }
  73393. declare module BABYLON {
  73394. /** @hidden */
  73395. export var triplanarVertexShader: {
  73396. name: string;
  73397. shader: string;
  73398. };
  73399. }
  73400. declare module BABYLON {
  73401. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73402. mixTexture: BABYLON.BaseTexture;
  73403. private _diffuseTextureX;
  73404. diffuseTextureX: BABYLON.BaseTexture;
  73405. private _diffuseTextureY;
  73406. diffuseTextureY: BABYLON.BaseTexture;
  73407. private _diffuseTextureZ;
  73408. diffuseTextureZ: BABYLON.BaseTexture;
  73409. private _normalTextureX;
  73410. normalTextureX: BABYLON.BaseTexture;
  73411. private _normalTextureY;
  73412. normalTextureY: BABYLON.BaseTexture;
  73413. private _normalTextureZ;
  73414. normalTextureZ: BABYLON.BaseTexture;
  73415. tileSize: number;
  73416. diffuseColor: BABYLON.Color3;
  73417. specularColor: BABYLON.Color3;
  73418. specularPower: number;
  73419. private _disableLighting;
  73420. disableLighting: boolean;
  73421. private _maxSimultaneousLights;
  73422. maxSimultaneousLights: number;
  73423. private _renderId;
  73424. constructor(name: string, scene: BABYLON.Scene);
  73425. needAlphaBlending(): boolean;
  73426. needAlphaTesting(): boolean;
  73427. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73428. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73429. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73430. getAnimatables(): BABYLON.IAnimatable[];
  73431. getActiveTextures(): BABYLON.BaseTexture[];
  73432. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73433. dispose(forceDisposeEffect?: boolean): void;
  73434. clone(name: string): TriPlanarMaterial;
  73435. serialize(): any;
  73436. getClassName(): string;
  73437. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73438. }
  73439. }
  73440. declare module BABYLON {
  73441. /** @hidden */
  73442. export var waterPixelShader: {
  73443. name: string;
  73444. shader: string;
  73445. };
  73446. }
  73447. declare module BABYLON {
  73448. /** @hidden */
  73449. export var waterVertexShader: {
  73450. name: string;
  73451. shader: string;
  73452. };
  73453. }
  73454. declare module BABYLON {
  73455. export class WaterMaterial extends BABYLON.PushMaterial {
  73456. renderTargetSize: BABYLON.Vector2;
  73457. private _bumpTexture;
  73458. bumpTexture: BABYLON.BaseTexture;
  73459. diffuseColor: BABYLON.Color3;
  73460. specularColor: BABYLON.Color3;
  73461. specularPower: number;
  73462. private _disableLighting;
  73463. disableLighting: boolean;
  73464. private _maxSimultaneousLights;
  73465. maxSimultaneousLights: number;
  73466. /**
  73467. * @param {number}: Represents the wind force
  73468. */
  73469. windForce: number;
  73470. /**
  73471. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73472. */
  73473. windDirection: BABYLON.Vector2;
  73474. /**
  73475. * @param {number}: Wave height, represents the height of the waves
  73476. */
  73477. waveHeight: number;
  73478. /**
  73479. * @param {number}: Bump height, represents the bump height related to the bump map
  73480. */
  73481. bumpHeight: number;
  73482. /**
  73483. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73484. */
  73485. private _bumpSuperimpose;
  73486. bumpSuperimpose: boolean;
  73487. /**
  73488. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73489. */
  73490. private _fresnelSeparate;
  73491. fresnelSeparate: boolean;
  73492. /**
  73493. * @param {boolean}: bump Waves modify the reflection.
  73494. */
  73495. private _bumpAffectsReflection;
  73496. bumpAffectsReflection: boolean;
  73497. /**
  73498. * @param {number}: The water color blended with the refraction (near)
  73499. */
  73500. waterColor: BABYLON.Color3;
  73501. /**
  73502. * @param {number}: The blend factor related to the water color
  73503. */
  73504. colorBlendFactor: number;
  73505. /**
  73506. * @param {number}: The water color blended with the reflection (far)
  73507. */
  73508. waterColor2: BABYLON.Color3;
  73509. /**
  73510. * @param {number}: The blend factor related to the water color (reflection, far)
  73511. */
  73512. colorBlendFactor2: number;
  73513. /**
  73514. * @param {number}: Represents the maximum length of a wave
  73515. */
  73516. waveLength: number;
  73517. /**
  73518. * @param {number}: Defines the waves speed
  73519. */
  73520. waveSpeed: number;
  73521. /**
  73522. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73523. * will avoid calculating useless pixels in the pixel shader of the water material.
  73524. */
  73525. disableClipPlane: boolean;
  73526. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73527. private _mesh;
  73528. private _refractionRTT;
  73529. private _reflectionRTT;
  73530. private _reflectionTransform;
  73531. private _lastTime;
  73532. private _lastDeltaTime;
  73533. private _renderId;
  73534. private _useLogarithmicDepth;
  73535. private _waitingRenderList;
  73536. private _imageProcessingConfiguration;
  73537. private _imageProcessingObserver;
  73538. /**
  73539. * Gets a boolean indicating that current material needs to register RTT
  73540. */
  73541. readonly hasRenderTargetTextures: boolean;
  73542. /**
  73543. * Constructor
  73544. */
  73545. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73546. useLogarithmicDepth: boolean;
  73547. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73548. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73549. addToRenderList(node: any): void;
  73550. enableRenderTargets(enable: boolean): void;
  73551. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73552. readonly renderTargetsEnabled: boolean;
  73553. needAlphaBlending(): boolean;
  73554. needAlphaTesting(): boolean;
  73555. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73556. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73557. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73558. private _createRenderTargets;
  73559. getAnimatables(): BABYLON.IAnimatable[];
  73560. getActiveTextures(): BABYLON.BaseTexture[];
  73561. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73562. dispose(forceDisposeEffect?: boolean): void;
  73563. clone(name: string): WaterMaterial;
  73564. serialize(): any;
  73565. getClassName(): string;
  73566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73567. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73568. }
  73569. }
  73570. declare module BABYLON {
  73571. /** @hidden */
  73572. export var asciiartPixelShader: {
  73573. name: string;
  73574. shader: string;
  73575. };
  73576. }
  73577. declare module BABYLON {
  73578. /**
  73579. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73580. *
  73581. * It basically takes care rendering the font front the given font size to a texture.
  73582. * This is used later on in the postprocess.
  73583. */
  73584. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73585. private _font;
  73586. private _text;
  73587. private _charSize;
  73588. /**
  73589. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73590. */
  73591. readonly charSize: number;
  73592. /**
  73593. * Create a new instance of the Ascii Art FontTexture class
  73594. * @param name the name of the texture
  73595. * @param font the font to use, use the W3C CSS notation
  73596. * @param text the caracter set to use in the rendering.
  73597. * @param scene the scene that owns the texture
  73598. */
  73599. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73600. /**
  73601. * Gets the max char width of a font.
  73602. * @param font the font to use, use the W3C CSS notation
  73603. * @return the max char width
  73604. */
  73605. private getFontWidth;
  73606. /**
  73607. * Gets the max char height of a font.
  73608. * @param font the font to use, use the W3C CSS notation
  73609. * @return the max char height
  73610. */
  73611. private getFontHeight;
  73612. /**
  73613. * Clones the current AsciiArtTexture.
  73614. * @return the clone of the texture.
  73615. */
  73616. clone(): AsciiArtFontTexture;
  73617. /**
  73618. * Parses a json object representing the texture and returns an instance of it.
  73619. * @param source the source JSON representation
  73620. * @param scene the scene to create the texture for
  73621. * @return the parsed texture
  73622. */
  73623. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73624. }
  73625. /**
  73626. * Option available in the Ascii Art Post Process.
  73627. */
  73628. export interface IAsciiArtPostProcessOptions {
  73629. /**
  73630. * The font to use following the w3c font definition.
  73631. */
  73632. font?: string;
  73633. /**
  73634. * The character set to use in the postprocess.
  73635. */
  73636. characterSet?: string;
  73637. /**
  73638. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73639. * This number is defined between 0 and 1;
  73640. */
  73641. mixToTile?: number;
  73642. /**
  73643. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73644. * This number is defined between 0 and 1;
  73645. */
  73646. mixToNormal?: number;
  73647. }
  73648. /**
  73649. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73650. *
  73651. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73652. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73653. */
  73654. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73655. /**
  73656. * The font texture used to render the char in the post process.
  73657. */
  73658. private _asciiArtFontTexture;
  73659. /**
  73660. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73661. * This number is defined between 0 and 1;
  73662. */
  73663. mixToTile: number;
  73664. /**
  73665. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73666. * This number is defined between 0 and 1;
  73667. */
  73668. mixToNormal: number;
  73669. /**
  73670. * Instantiates a new Ascii Art Post Process.
  73671. * @param name the name to give to the postprocess
  73672. * @camera the camera to apply the post process to.
  73673. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73674. */
  73675. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73676. }
  73677. }
  73678. declare module BABYLON {
  73679. /** @hidden */
  73680. export var digitalrainPixelShader: {
  73681. name: string;
  73682. shader: string;
  73683. };
  73684. }
  73685. declare module BABYLON {
  73686. /**
  73687. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73688. *
  73689. * It basically takes care rendering the font front the given font size to a texture.
  73690. * This is used later on in the postprocess.
  73691. */
  73692. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73693. private _font;
  73694. private _text;
  73695. private _charSize;
  73696. /**
  73697. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73698. */
  73699. readonly charSize: number;
  73700. /**
  73701. * Create a new instance of the Digital Rain FontTexture class
  73702. * @param name the name of the texture
  73703. * @param font the font to use, use the W3C CSS notation
  73704. * @param text the caracter set to use in the rendering.
  73705. * @param scene the scene that owns the texture
  73706. */
  73707. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73708. /**
  73709. * Gets the max char width of a font.
  73710. * @param font the font to use, use the W3C CSS notation
  73711. * @return the max char width
  73712. */
  73713. private getFontWidth;
  73714. /**
  73715. * Gets the max char height of a font.
  73716. * @param font the font to use, use the W3C CSS notation
  73717. * @return the max char height
  73718. */
  73719. private getFontHeight;
  73720. /**
  73721. * Clones the current DigitalRainFontTexture.
  73722. * @return the clone of the texture.
  73723. */
  73724. clone(): DigitalRainFontTexture;
  73725. /**
  73726. * Parses a json object representing the texture and returns an instance of it.
  73727. * @param source the source JSON representation
  73728. * @param scene the scene to create the texture for
  73729. * @return the parsed texture
  73730. */
  73731. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73732. }
  73733. /**
  73734. * Option available in the Digital Rain Post Process.
  73735. */
  73736. export interface IDigitalRainPostProcessOptions {
  73737. /**
  73738. * The font to use following the w3c font definition.
  73739. */
  73740. font?: string;
  73741. /**
  73742. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73743. * This number is defined between 0 and 1;
  73744. */
  73745. mixToTile?: number;
  73746. /**
  73747. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73748. * This number is defined between 0 and 1;
  73749. */
  73750. mixToNormal?: number;
  73751. }
  73752. /**
  73753. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73754. *
  73755. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73756. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73757. */
  73758. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73759. /**
  73760. * The font texture used to render the char in the post process.
  73761. */
  73762. private _digitalRainFontTexture;
  73763. /**
  73764. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73765. * This number is defined between 0 and 1;
  73766. */
  73767. mixToTile: number;
  73768. /**
  73769. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73770. * This number is defined between 0 and 1;
  73771. */
  73772. mixToNormal: number;
  73773. /**
  73774. * Instantiates a new Digital Rain Post Process.
  73775. * @param name the name to give to the postprocess
  73776. * @camera the camera to apply the post process to.
  73777. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73778. */
  73779. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73780. }
  73781. }
  73782. declare module BABYLON {
  73783. /** @hidden */
  73784. export var oceanPostProcessPixelShader: {
  73785. name: string;
  73786. shader: string;
  73787. };
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Option available in the Ocean Post Process.
  73792. */
  73793. export interface IOceanPostProcessOptions {
  73794. /**
  73795. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73796. */
  73797. reflectionSize?: number | {
  73798. width: number;
  73799. height: number;
  73800. } | {
  73801. ratio: number;
  73802. };
  73803. /**
  73804. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73805. */
  73806. refractionSize?: number | {
  73807. width: number;
  73808. height: number;
  73809. } | {
  73810. ratio: number;
  73811. };
  73812. }
  73813. /**
  73814. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73815. *
  73816. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73817. * Example usage:
  73818. * var pp = new OceanPostProcess("myOcean", camera);
  73819. * pp.reflectionEnabled = true;
  73820. * pp.refractionEnabled = true;
  73821. */
  73822. export class OceanPostProcess extends BABYLON.PostProcess {
  73823. /**
  73824. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73825. */
  73826. /**
  73827. * Sets weither or not the real-time reflection is enabled on the ocean.
  73828. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73829. */
  73830. reflectionEnabled: boolean;
  73831. /**
  73832. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73833. */
  73834. /**
  73835. * Sets weither or not the real-time refraction is enabled on the ocean.
  73836. * Is set to true, the refraction render target texture will be used as refraction texture.
  73837. */
  73838. refractionEnabled: boolean;
  73839. /**
  73840. * Gets wether or not the post-processes is supported by the running hardware.
  73841. * This requires draw buffer supports.
  73842. */
  73843. readonly isSupported: boolean;
  73844. /**
  73845. * This is the reflection mirror texture used to display reflections on the ocean.
  73846. * By default, render list is empty.
  73847. */
  73848. reflectionTexture: BABYLON.MirrorTexture;
  73849. /**
  73850. * This is the refraction render target texture used to display refraction on the ocean.
  73851. * By default, render list is empty.
  73852. */
  73853. refractionTexture: BABYLON.RenderTargetTexture;
  73854. private _time;
  73855. private _cameraRotation;
  73856. private _cameraViewMatrix;
  73857. private _reflectionEnabled;
  73858. private _refractionEnabled;
  73859. private _geometryRenderer;
  73860. /**
  73861. * Instantiates a new Ocean Post Process.
  73862. * @param name the name to give to the postprocess.
  73863. * @camera the camera to apply the post process to.
  73864. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73865. */
  73866. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73867. /**
  73868. * Returns the appropriate defines according to the current configuration.
  73869. */
  73870. private _getDefines;
  73871. /**
  73872. * Computes the current camera rotation as the shader requires a camera rotation.
  73873. */
  73874. private _computeCameraRotation;
  73875. }
  73876. }
  73877. declare module BABYLON {
  73878. /** @hidden */
  73879. export var brickProceduralTexturePixelShader: {
  73880. name: string;
  73881. shader: string;
  73882. };
  73883. }
  73884. declare module BABYLON {
  73885. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73886. private _numberOfBricksHeight;
  73887. private _numberOfBricksWidth;
  73888. private _jointColor;
  73889. private _brickColor;
  73890. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73891. updateShaderUniforms(): void;
  73892. numberOfBricksHeight: number;
  73893. numberOfBricksWidth: number;
  73894. jointColor: BABYLON.Color3;
  73895. brickColor: BABYLON.Color3;
  73896. /**
  73897. * Serializes this brick procedural texture
  73898. * @returns a serialized brick procedural texture object
  73899. */
  73900. serialize(): any;
  73901. /**
  73902. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73903. * @param parsedTexture defines parsed texture data
  73904. * @param scene defines the current scene
  73905. * @param rootUrl defines the root URL containing brick procedural texture information
  73906. * @returns a parsed Brick Procedural BABYLON.Texture
  73907. */
  73908. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73909. }
  73910. }
  73911. declare module BABYLON {
  73912. /** @hidden */
  73913. export var cloudProceduralTexturePixelShader: {
  73914. name: string;
  73915. shader: string;
  73916. };
  73917. }
  73918. declare module BABYLON {
  73919. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73920. private _skyColor;
  73921. private _cloudColor;
  73922. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73923. updateShaderUniforms(): void;
  73924. skyColor: BABYLON.Color4;
  73925. cloudColor: BABYLON.Color4;
  73926. /**
  73927. * Serializes this cloud procedural texture
  73928. * @returns a serialized cloud procedural texture object
  73929. */
  73930. serialize(): any;
  73931. /**
  73932. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73933. * @param parsedTexture defines parsed texture data
  73934. * @param scene defines the current scene
  73935. * @param rootUrl defines the root URL containing cloud procedural texture information
  73936. * @returns a parsed Cloud Procedural BABYLON.Texture
  73937. */
  73938. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73939. }
  73940. }
  73941. declare module BABYLON {
  73942. /** @hidden */
  73943. export var fireProceduralTexturePixelShader: {
  73944. name: string;
  73945. shader: string;
  73946. };
  73947. }
  73948. declare module BABYLON {
  73949. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73950. private _time;
  73951. private _speed;
  73952. private _autoGenerateTime;
  73953. private _fireColors;
  73954. private _alphaThreshold;
  73955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73956. updateShaderUniforms(): void;
  73957. render(useCameraPostProcess?: boolean): void;
  73958. static readonly PurpleFireColors: BABYLON.Color3[];
  73959. static readonly GreenFireColors: BABYLON.Color3[];
  73960. static readonly RedFireColors: BABYLON.Color3[];
  73961. static readonly BlueFireColors: BABYLON.Color3[];
  73962. autoGenerateTime: boolean;
  73963. fireColors: BABYLON.Color3[];
  73964. time: number;
  73965. speed: BABYLON.Vector2;
  73966. alphaThreshold: number;
  73967. /**
  73968. * Serializes this fire procedural texture
  73969. * @returns a serialized fire procedural texture object
  73970. */
  73971. serialize(): any;
  73972. /**
  73973. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73974. * @param parsedTexture defines parsed texture data
  73975. * @param scene defines the current scene
  73976. * @param rootUrl defines the root URL containing fire procedural texture information
  73977. * @returns a parsed Fire Procedural BABYLON.Texture
  73978. */
  73979. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73980. }
  73981. }
  73982. declare module BABYLON {
  73983. /** @hidden */
  73984. export var grassProceduralTexturePixelShader: {
  73985. name: string;
  73986. shader: string;
  73987. };
  73988. }
  73989. declare module BABYLON {
  73990. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73991. private _grassColors;
  73992. private _groundColor;
  73993. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73994. updateShaderUniforms(): void;
  73995. grassColors: BABYLON.Color3[];
  73996. groundColor: BABYLON.Color3;
  73997. /**
  73998. * Serializes this grass procedural texture
  73999. * @returns a serialized grass procedural texture object
  74000. */
  74001. serialize(): any;
  74002. /**
  74003. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  74004. * @param parsedTexture defines parsed texture data
  74005. * @param scene defines the current scene
  74006. * @param rootUrl defines the root URL containing grass procedural texture information
  74007. * @returns a parsed Grass Procedural BABYLON.Texture
  74008. */
  74009. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  74010. }
  74011. }
  74012. declare module BABYLON {
  74013. /** @hidden */
  74014. export var marbleProceduralTexturePixelShader: {
  74015. name: string;
  74016. shader: string;
  74017. };
  74018. }
  74019. declare module BABYLON {
  74020. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  74021. private _numberOfTilesHeight;
  74022. private _numberOfTilesWidth;
  74023. private _amplitude;
  74024. private _jointColor;
  74025. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74026. updateShaderUniforms(): void;
  74027. numberOfTilesHeight: number;
  74028. amplitude: number;
  74029. numberOfTilesWidth: number;
  74030. jointColor: BABYLON.Color3;
  74031. /**
  74032. * Serializes this marble procedural texture
  74033. * @returns a serialized marble procedural texture object
  74034. */
  74035. serialize(): any;
  74036. /**
  74037. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  74038. * @param parsedTexture defines parsed texture data
  74039. * @param scene defines the current scene
  74040. * @param rootUrl defines the root URL containing marble procedural texture information
  74041. * @returns a parsed Marble Procedural BABYLON.Texture
  74042. */
  74043. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  74044. }
  74045. }
  74046. declare module BABYLON {
  74047. /** @hidden */
  74048. export var normalMapProceduralTexturePixelShader: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module BABYLON {
  74054. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  74055. private _baseTexture;
  74056. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74057. updateShaderUniforms(): void;
  74058. render(useCameraPostProcess?: boolean): void;
  74059. resize(size: any, generateMipMaps: any): void;
  74060. baseTexture: BABYLON.Texture;
  74061. /**
  74062. * Serializes this normal map procedural texture
  74063. * @returns a serialized normal map procedural texture object
  74064. */
  74065. serialize(): any;
  74066. /**
  74067. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  74068. * @param parsedTexture defines parsed texture data
  74069. * @param scene defines the current scene
  74070. * @param rootUrl defines the root URL containing normal map procedural texture information
  74071. * @returns a parsed Normal Map Procedural BABYLON.Texture
  74072. */
  74073. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  74074. }
  74075. }
  74076. declare module BABYLON {
  74077. /** @hidden */
  74078. export var perlinNoiseProceduralTexturePixelShader: {
  74079. name: string;
  74080. shader: string;
  74081. };
  74082. }
  74083. declare module BABYLON {
  74084. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  74085. time: number;
  74086. timeScale: number;
  74087. translationSpeed: number;
  74088. private _currentTranslation;
  74089. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74090. updateShaderUniforms(): void;
  74091. render(useCameraPostProcess?: boolean): void;
  74092. resize(size: any, generateMipMaps: any): void;
  74093. /**
  74094. * Serializes this perlin noise procedural texture
  74095. * @returns a serialized perlin noise procedural texture object
  74096. */
  74097. serialize(): any;
  74098. /**
  74099. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  74100. * @param parsedTexture defines parsed texture data
  74101. * @param scene defines the current scene
  74102. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  74103. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  74104. */
  74105. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  74106. }
  74107. }
  74108. declare module BABYLON {
  74109. /** @hidden */
  74110. export var roadProceduralTexturePixelShader: {
  74111. name: string;
  74112. shader: string;
  74113. };
  74114. }
  74115. declare module BABYLON {
  74116. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  74117. private _roadColor;
  74118. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74119. updateShaderUniforms(): void;
  74120. roadColor: BABYLON.Color3;
  74121. /**
  74122. * Serializes this road procedural texture
  74123. * @returns a serialized road procedural texture object
  74124. */
  74125. serialize(): any;
  74126. /**
  74127. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  74128. * @param parsedTexture defines parsed texture data
  74129. * @param scene defines the current scene
  74130. * @param rootUrl defines the root URL containing road procedural texture information
  74131. * @returns a parsed Road Procedural BABYLON.Texture
  74132. */
  74133. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  74134. }
  74135. }
  74136. declare module BABYLON {
  74137. /** @hidden */
  74138. export var starfieldProceduralTexturePixelShader: {
  74139. name: string;
  74140. shader: string;
  74141. };
  74142. }
  74143. declare module BABYLON {
  74144. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  74145. private _time;
  74146. private _alpha;
  74147. private _beta;
  74148. private _zoom;
  74149. private _formuparam;
  74150. private _stepsize;
  74151. private _tile;
  74152. private _brightness;
  74153. private _darkmatter;
  74154. private _distfading;
  74155. private _saturation;
  74156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74157. updateShaderUniforms(): void;
  74158. time: number;
  74159. alpha: number;
  74160. beta: number;
  74161. formuparam: number;
  74162. stepsize: number;
  74163. zoom: number;
  74164. tile: number;
  74165. brightness: number;
  74166. darkmatter: number;
  74167. distfading: number;
  74168. saturation: number;
  74169. /**
  74170. * Serializes this starfield procedural texture
  74171. * @returns a serialized starfield procedural texture object
  74172. */
  74173. serialize(): any;
  74174. /**
  74175. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  74176. * @param parsedTexture defines parsed texture data
  74177. * @param scene defines the current scene
  74178. * @param rootUrl defines the root URL containing startfield procedural texture information
  74179. * @returns a parsed Starfield Procedural BABYLON.Texture
  74180. */
  74181. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  74182. }
  74183. }
  74184. declare module BABYLON {
  74185. /** @hidden */
  74186. export var woodProceduralTexturePixelShader: {
  74187. name: string;
  74188. shader: string;
  74189. };
  74190. }
  74191. declare module BABYLON {
  74192. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  74193. private _ampScale;
  74194. private _woodColor;
  74195. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74196. updateShaderUniforms(): void;
  74197. ampScale: number;
  74198. woodColor: BABYLON.Color3;
  74199. /**
  74200. * Serializes this wood procedural texture
  74201. * @returns a serialized wood procedural texture object
  74202. */
  74203. serialize(): any;
  74204. /**
  74205. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  74206. * @param parsedTexture defines parsed texture data
  74207. * @param scene defines the current scene
  74208. * @param rootUrl defines the root URL containing wood procedural texture information
  74209. * @returns a parsed Wood Procedural BABYLON.Texture
  74210. */
  74211. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  74212. }
  74213. }